I am trying to write a socket system that is to handle extremely long messages (it handles a chat system). I am trying to use a const int to initialize an array, which DOES compile, but I am warned about ISO C++ forbidding it. Can someone shed some light on the situation?
Here is an example of how it would be used (this is to avoid writing a byte-remaining multi-recieve system (which I already have, but I feel this would be more efficient)).
const int BUFFERLEN = atoi(api_GETVALUE(1,inbuffer).c_str()); //that is my API call
if(BUFFERLEN != -1) { //it returns "-1" on error
char INBUFFER[BUFFERLEN];
recv(SOCK,INBUFFER,sizeof(INBUFFER),0);
}
Is this acceptable to do at all, or should I stick with the multi-recieve-until-done method?
Thanks,
Collin
1 Answer