I have a char array of size 512 i.e
char buffer [512];
This variable after some point is modified to this
buffer [40] = '\0';
What does this assignment does to the variable? Does it initialize the first 40 char in the array to null?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It assigns only the 41st char in the array to
\0. Thus now the string consists of what the chars represent in the first 40 elements of the array i.e 0 to 39th indices (assuming there were no otherNULcharacters in any of the previous elements -Thanks Kerrek SB!!) .Hope this helps!