In C, can I say a white space in a string has a NULL type, or something else?
In C, which character represents the termination of a string?
views:
136answers:
4The null character (ASCII value 0, '\0'
as a character literal) terminates a string in C. This character is not usually regarded as a whitespace character.
The space in the middle of this string for example: "Hello world"
is the character with ASCII value 32. This is not the same as NULL or \0
.
In C, can I say a white space in a string has a NULL type, or something else?
I'm not sure what you mean by a NULL type. A white space is a space character or tab or carriage return.
In C, which character represents the termination of a string?
The '\0'
character is the termination of a string.
The termination character is a byte with value 0. Expressed as a literal character, it is '\0'
.
Your first question about white space having a NULL type doesn't make any sense.
The following characters are regarded as "whitespace" in the sense that the isspace() function returns non-zero:
- space (ASCII 0x32, C literal
' '
) - tab (ASCII 0x09, C literal
'\t'
) - vertical tab (ASCII 0x0B, C literal
'\v'
) - form feed (ASCII 0x0C, C literal
'\f'
) - carriage return (ASCII 0x0E, C literal
'\r'
) - newline (ASCII 0x0A, C literal
'\n'
)
The string terminator is the ASCII NUL (0x00) character; it generally has no effect on the cursor if you attempt to output it to a console or terminal.