开发者

Wondering in C strings, NULL, white spaces

In C, can I say a white space in a string has a NUL开发者_如何学PythonL type, or something else?

In C, which character represents the termination of a string?


The 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 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜