Reading an HTTP server response into a char array in Arduino

After I make a HTTP POST request to a server I can see the response when I use this code in the void setup() block:

long timeOut = 5000;
long lastTime = millis();

while((millis()-lastTime) < timeOut)
{ // Wait for incoming response from server
  while (client.available()) 
  { // Characters incoming from the server
    char c = client.read();            // Read characters
    Serial.write(c);
  }
}

However, when I change this code as shown below to read the characters into an array I see nothing. How do I do this?

long timeOut = 5000;
long lastTime = millis();
long ctr = 0;
char chArray[512];

while((millis()-lastTime) < timeOut)
{ // Wait for incoming response from server
  while (client.available()) 
  { // Characters incoming from the server
    chArray[ctr] = client.read();            // Read characters
    ctr++;
  }
}

You don't seem to be doing a Serial.print anywhere...

There is a serial.write in the first version where the response is printed on to the serial monitor. In the section be one the response is supposed to collect in the chat array directly (but it does not).

electrophile:
There is a serial.write in the first version where the response is printed on to the serial monitor. In the section be one the response is supposed to collect in the chat array directly (but it does not).

OK, presumably that's just a snippet of code, right? And you find out somewhere else that there's nothing and/or some problem with your char array?

Have you considered simply adding Serial.write(chArray[ctr]) during the loop? Should then be identical to the first one, except you get a copy in your array. Or add Serial.write(ctr); outside of the timeout loop, just to prove it actually saw the characters.

The only other thing I can think of, and it's guessing because you've not posted the rest of your code; is are you explicitly adding an 0x00 character at the end of the array before treating it as a string?