Strings are a fundamental concept in software engineering, but they are not a built-in type in C. Null-terminated byte strings (NTBS) consist of a contiguous sequence of characters terminated by and including the first null character. The C programming language supports the following types of null-terminated byte strings: single-byte character strings, multibyte character strings, and wide character strings. Single-byte and multibyte character strings are both described as null-terminated byte strings.
A pointer to a single-byte or multibyte character string points to its initial character. The length of the string is the number of bytes preceding the null character, and the value of the string is the sequence of the values of the contained characters, in order.
...
signed char and unsigned char:
- Suitable for small integer values.
"plain" char:
- The type of each element of a string literal.
- Used for character data (where signedness has little meaning) as opposed to integer data.
int:
- Used for data that could be either
EOF(a negative value) or character data interpreted asunsigned charand then converted toint. Therefore, returned byfgetc(),getc(),getchar(), andungetc(). Also, accepted by the character handling functions from<ctype.h>, because they might be passed the result offgetc()et al. - The type of a character constant. Its value is that of a plain
charconverted toint.
unsigned char:
- Used internally for string comparison functions, even though these operate on character data. Therefore, the result of a string comparison does not depend on whether plain
charis signed. - Used for situations where the object being manipulated might be of any type, and it is necessary to access all bits of that object, as with
fwrite().
...