String Manipulation

Routine

Attributes

Description

strcat

Concatenates two strings

strchr

reentrant

Returns a pointer to the first occurrence of a specified character in a string

strcmp

reentrant

Compares two strings

strcpy

reentrant

Copies one string to another

strcspn

Returns the index of the first character in a string that matches any character in a second string

strlen

reentrant

Returns the length of a string

strncat

Concatenates up to a specified number of characters from one string to another

strncmp

Compares two strings up to a specified number of characters

strncpy

Copies up to a specified number of characters from one string to another

strpbrk

Returns a pointer to the first character in a string that matches any character in a second string

strpos

reentrant

Returns the index of the first occurrence of a specified character in a string

strrchr

reentrant

Returns a pointer to the last occurrence of a specified character in a string

strrpbrk

Returns a pointer to the last character in a string that matches any character in a second string

strrpos

reentrant

Returns the index of the last occurrence of a specified character in a string

strspn

Returns the index of the first character in a string that does not match any character in a second string

The string routines are implemented as functions and are prototyped in the STRING.H include file.

The string routines provide you with the following operations to perform on character strings:

    Copying strings

    Appending one string to the end of another

    Comparing two strings

    Locating one or more characters from a specified set in a string

All string functions operate on null-terminated character strings. To work on non-terminated strings, use the buffer manipulation routines described earlier in this section.