A string constant is a sequence of characters or symbols between a pair of double-quote characters.
The following statements illustrate this:
printf("This is a string."); printf("This is on\ntwo lines!"); printf("\" \\\".");
The first string is a straightforward sequence of letters followed by a period.
The printf() function will output this string as:
This is a string.
The second string has a newline character embedded in it, so the string will be displayed over two lines:
This is on two lines!
The third string used escape sequence.
A special character with the code value 0 is added to the end of each string to mark where it ends.
This character is known as the null character and you write it as \0.
A string is always terminated by a null character, so the length of a string is always one greater than the number of characters in the string.
If you add \0 to your string. Your string will be cut.
#include <stdio.h> int main(void) { printf("The character \0 is used to terminate a string."); return 0;/*w w w . j a v a 2 s . co m*/ }