question about nul termination
for a char array define as below,
char buff[6] = "hello";
when cout << buff; the result is:
hello
right?
when we debug that , we found that:
buff[0] = h
buff[1] = e
buff[2] = l
buff[3] = l
buff[4] = o
buff[5] = 0 (nul terminater)
buff[6] = ? (unknown character)
i would like to ask:
1.) we can see "hello" after running the program but not "hello0?", is it because when the nul terminater reached, the progaram will stop printing the character?
2.) for readfile example like below:
char buff2[256]
readfile ( handle, buff2, 256, &size,NULL)
i.e. i read 256 characters to the array buff2 from the com port, will the program add the nul terminater to the char array??