If you make a null-terminated string, then call printf() on it, will the null character cause a gap at the end of it?
What happens if you call printf() and the string isn't null-terminated?
If you make a null-terminated string, then call printf() on it, will the null character cause a gap at the end of it?
What happens if you call printf() and the string isn't null-terminated?
No, it will not since the null terminator is not printed.Originally Posted by Tom_Arch
Undefined behaviour unless you also specify a precision that is less than the number of characters in the array. Note that without a null terminator, it is not a string, by standard definition.Originally Posted by Tom_Arch
EDIT:
From context and in text, Tom_Arch is talking about a null character, not NULL.Originally Posted by sbattu
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
NULL is a macro for a null pointer constant. Although in terms of integer value they are equal and may even have the same type, the null character clearly is not (at least semantically) a null pointer constant.Originally Posted by Tom_Arch
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)