Strange question about reading the client data from Ethernet Shield

The function below is used to read the data from a website, and client is running as EthernetClient, however,

EthernetClient client; char input[600]; ...... void ReceiveEthernetResponse1() { int index = 0; while(client1.available() > 0) { char c =; ** input[index] = c; // This line cause the problem of receiving data and sending data out.** Serial.println(input[index]); index++; }

The highlighted line has the problem. Everytime when it is there, the communication is stopped and I cannot receive any information. But when it is removed, it is OK to receive and print the data on serial port. Any suggestions? Thanks.

You have not bounds checked the variable called index.

Its possible that index++ will eventually make index > the size of the array

char input[600];

minimum you should do is

 while(client1.available() > 0 && index < 600)

And if you are using the bounds value of 600 in more than one place you should use a #define for it and use in both places


#defined INPUT_BUFFER_SIZE 600

It's far more likely that the cause of your problem is that your array is WAY too big. I'd wager that you are using more than every last byte of SRAM you have.