C Strings
- There is no string type in C.
-
- C does have char arrays ...
- ... and a library of functions that treat special char arrays as
strings
- an array of characters with a terminating null byte ('\0')
is treated as a string
string.h
(man string
)
- string functions include:
strlen
(man strlen
)
strcpy
, strncpy
strcmp
, strncmp
strstr
strtok
- etc.
-
- Even though C does not have a string type, it does have string
constants, e.g., "This is a string."
T | h | i | s |
| i | s | |
a | | s | t |
r | i | n | g | . | \0 |
Alyce Brady, Kalamazoo College