2.14 String Manipulation

The string functions are declared in the include file STRING.H. They allow you to compare strings, copy them, search for strings and characters, and perform various other operations.

Routines beginning with _f are model-independent versions of the corresponding routines and are useful in mixed-model programs. These routines can be called from any point in the program, regardless of which model is being used.

Routine Use

strcat, _fstrcat Append one string to another
strchr, _fstrchr Find first occurrence of a given character in a string
strcmp, _fstrcmp Compare two strings
strcpy, _fstrcpy Copy one string to another
strcspn, _fstrcspn Find first occurrence of a character from a given character set in a string
_strdup, _fstrdup, _nstrdup Duplicate a string
strerror Maps an error number to a message string
_strerror Maps a user-defined error message to a string
_stricmp, _fstricmp Compare two strings without regard to case
strlen, _fstrlen Find length of string
_strlwr, _fstrlwr Convert string to lowercase
strncat, _fstrncat Append characters of a string
strncmp, _fstrncmp Compare characters of two strings
strncpy, _fstrncpy Copy characters of one string to another
_strnicmp, _fstrnicmp Compare characters of two strings without regard to case
_strnset, _fstrnset Set characters of a string to a given character
strpbrk, _fstrpbrk Find first occurrence of a character from one string in another
strrchr, _fstrrchr Find last occurrence of a given character in string
_strrev, _fstrrev Reverse a string
_strset, _fstrset Set all characters of a string to a given character
strspn, _fstrspn Find first substring from a given character set in a string
strstr, _fstrstr Find first occurrence of a given string in another string
strtok, _fstrtok Find next token in a string
_strupr, _fstrupr Convert a string to uppercase

All string functions work on null-terminated character strings. When working with character arrays that do not end with a null character, you can use the buffer-manipulation routines, described in “Buffer Manipulation”.