Why Commenting Serial.print() gives me a different value? I am working on with Cypress and Arduino.I am trying to transfer the data from cypress and printing it to the Serial Monitor or Arduino. but the thing is when I am using Serial.print(j) it is showing the right value of i (See in the code about what is i and j), but when I comment or remove Serial.print(j) it is showing the wrong value of i
For example, suppose cypress is sending data 00001934a
and then I am reading this value using 

int j = mySerial.read()-'0';
// -'0' is for chaging ascii data to normal integer
//for example ascii value of `0` is 48 
//so mySerial will read 48 
// and exprerssion value will become `48-48 = 0`


My code

#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(57600);
 while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

mySerial.begin(4800);
}

int  i = 0; 
int j = 0;
void loop() { 
if (mySerial.available()) {

        while(j!=49){
        i = i*10 + j;
        j = mySerial.read()-'0';
         //49 is the ascii value of a, I am using this for acting like 
         //a flag, so that i can see the break in data


        Serial.println(j);//commeting this line is causing the problem
      }
   Serial.print(i);
   }
}


when the line is not commented the output was

0
0
0
0
1
9  
3
4
49
193 //this is the value of i which is correct one 


but when I comment the line Serial.println(j) the output was

   14569 // I don't know what the hack is this.


Hopefully the problem is understandable, but still, you can comment for more detail.
BTW I am using SoftwareSerial.
Majenko has correctly diagnosed your problem, and the blog post he
linked to is definitely a must-read. The suggested solution, namely
buffering the input until you can read a complete message, is presumably
the most standard way of dealing with an input stream.

It is, however, not the only option. Your idea of building the number
digit by digit can work, if implemented properly, and it can save you
the memory cost of the buffer. The key is to only read bytes when they
are available.

Below is a non-blocking implementation of a number reader that works
along the lines of your own code. This function only reads positive
numbers. It returns the number it just parsed upon reading a non-digit
character. In every other case it returns -1 to tell you there is no
input number available:

// Read an positive integer from a stream.
// Returns -1 if a complete integer is not available.
int readInt(Stream &amp;link)
{
    static bool got_a_digit = false;  // did we get a digit so far?
    static int i = 0;                 // the integer we are building
    if (link.available()) {
        char c = link.read();
        if (isdigit(c)) {
            i = 10 * i + (c - '0');
            got_a_digit = true;
        } else if (got_a_digit) {  // non-digit: return the number
            int i_copy = i;
            got_a_digit = false;   // reset for next reading
            i = 0;                 // ditto
            return i_copy;
        }
    }
    return -1;
}


And here is how you would use it:

void loop() {
    int i = readInt(mySerial);
    if (i != -1)
        Serial.println(i);
}