In C, strings end with a character with a null value (0). This can be written like this:
char zero = 0;
but this does not work inside the lines. There is a special syntax used in string literals where the backslash works like introducing an escape sequence and comes with various things.
One such sequence is a backslash, which simply means a character with a null value. So you can write things like this:
char hard[] = "this\0has embedded\0zero\0characters";
In another sequence, a backslash is used followed by the letter 'x' and one or two hexadecimal digits to represent the character with the specified code. Using this syntax, you can write a null byte as '\x0' , for example.
EDIT : re-reading the question, there are also supported such constants in the base of eight, that is, octal. They use a backslash followed by a digit zero, just like octal integer constants. Thus, '\00' is synonymous with '\0' .
This is sometimes useful when you need to build a string containing non-printable characters or special control characters.
There is also a set of one-character "named" special characters, such as '\n' for a new line, '\t' for TAB, etc.
unwind
source share