Problem with reading series of bytes over serial port
So, as result of Edgar Bonet's good remark, change

int i=0 , j=0;


to

int j = 0;


and define

int i = 0;


Outside the loop (as a global variable).

Also it is quite dangerous to define the length of the array as 10, while not checking for writing over the boundary of the array. What if you receive more bytes? The application might crash or give unpredictable behavior.