hey im getting an array bounds overflow....
any help would be greatly appreciated.Code:if (command == 1) { char outMessage[1] = "1"; nBytes = send(mySocket, outMessage, sizeof(outMessage), 0); printf("Message Sent : %s\n", outMessage); }
hey im getting an array bounds overflow....
any help would be greatly appreciated.Code:if (command == 1) { char outMessage[1] = "1"; nBytes = send(mySocket, outMessage, sizeof(outMessage), 0); printf("Message Sent : %s\n", outMessage); }
>>char outMessage[1] = "1";
The array size must be at least 2 to account for the null character implicit in string literals.
Thanks man i completely forgot about that. Damn short term memory. I cant try it now but im sure thats the problem.
So just say
char outMessage[] = "1";
and let the compiler do the counting for you
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.