If you carried out one of the experiments in the earlier sections of this chapter, you will have already encountered the strlen()function, which counts the number of characters (excluding the terminating nul character) in a given string. The following is a list of some useful functions and what they do:
- Copy, append, and cut strings:
- strcat(): Concatenates two strings. This appends a copy of one null-terminated string to the end of a target null-terminated string, then adds a terminating `\0' character. The target string must have sufficient space to hold theresult.
- strcpy(): Copies one string to another (including the terminating `\0' character).
- strtok(): Breaks a string into tokens or sub-strings.
- Compare strings:
- strcmp(): Compares two strings. Lexicographically compares two null-terminated strings.
- Search characters in strings:
- strchr(): Locates a character in a string. This finds the first...