Serial.flush();
Why? If the sending program sends a second packet before the Arduino has read the end of the first packet, random amounts of data will be thrown away.
If you don't want the sender to send more data before the first packet has been received, read, and processed, you need to implement handshaking. If the sender CAN send another packet before the first one has been completely read, then you must get rid of the flush(), or be prepared to deal with incomplete packets (that YOU have made incomplete by throwing away random amounts of data).
do{
if(Serial.available()>0){
input = Serial.read();
cArray[i]=input;
i++;
}
}while(input != '\r');
A do/while loop body will be executed at least once, before the test is performed. It is a very rarely used structure, as a result. I recommend that you not use it, either. Use a standard while loop, with proper initialization of the control variable.
When you do, you will see that you have already added the character in input to the end of the array before you test what it's value is.
You are not properly NULL terminating the array, either.
When printing stuff, just jamming numbers out to the serial monitor doesn't cut it. Some identifier of the data is needed, or white space between consecutive values, and blank lines between each execution of Serial.println().
Finally, what is sending the data to the Arduino? Typically, if that program is a Windows application, the carriage return gets translated to a carriage return, line feed combination. You are testing for one to stop the loop, but not ignoring the other.
Before adding input to the array, make sure it is not a carriage return and is not a line feed.
if(input != '\n' && input != '\r')
{
cArray[i++] = input;
cArray[i] = '\0';
}