VxWorks Reference Manual : Libraries
ansiString - ANSI string documentation
memchr( ) - search a block of memory for a character (ANSI)
memcmp( ) - compare two blocks of memory (ANSI)
memcpy( ) - copy memory from one location to another (ANSI)
memmove( ) - copy memory from one location to another (ANSI)
memset( ) - set a block of memory (ANSI)
strcat( ) - concatenate one string to another (ANSI)
strchr( ) - find the first occurrence of a character in a string (ANSI)
strcmp( ) - compare two strings lexicographically (ANSI)
strcoll( ) - compare two strings as appropriate to LC_COLLATE (ANSI)
strcpy( ) - copy one string to another (ANSI)
strcspn( ) - return the string length up to the first character from a given set (ANSI)
strerror_r( ) - map an error number to an error string (POSIX)
strerror( ) - map an error number to an error string (ANSI)
strlen( ) - determine the length of a string (ANSI)
strncat( ) - concatenate characters from one string to another (ANSI)
strncmp( ) - compare the first n characters of two strings (ANSI)
strncpy( ) - copy characters from one string to another (ANSI)
strpbrk( ) - find the first occurrence in a string of a character from a given set (ANSI)
strrchr( ) - find the last occurrence of a character in a string (ANSI)
strspn( ) - return the string length up to the first character not in a given set (ANSI)
strstr( ) - find the first occurrence of a substring in a string (ANSI)
strtok( ) - break down a string into tokens (ANSI)
strtok_r( ) - break down a string into tokens (reentrant) (POSIX)
strxfrm( ) - transform up to n characters of s2 into s1 (ANSI)
This library includes several standard ANSI routines. Note that where there is a pair of routines, such as div( ) and div_r( ), only the routine xxx_r( ) is reentrant. The xxx( ) routine is not reentrant.
The header string.h declares one type and several functions, and defines one macro useful for manipulating arrays of character type and other objects treated as array of character type. The type is size_t and the macro NULL. Various methods are used for determining the lengths of the arrays, but in all cases a char * or void * argument points to the initial (lowest addressed) character of the array. If an array is accessed beyond the end of an object, the behavior is undefined.
ansiString, American National Standard X3.159-1989
memchr( ) - search a block of memory for a character (ANSI)
void * memchr ( const void * m, /* block of memory */ int c, /* character to search for */ size_t n /* size of memory to search */ )
This routine searches for the first element of an array of unsigned char, beginning at the address m with size n, that equals c converted to an unsigned char.
string.h
If successful, it returns the address of the matching element; otherwise, it returns a null pointer.
memcmp( ) - compare two blocks of memory (ANSI)
int memcmp ( const void * s1, /* array 1 */ const void * s2, /* array 2 */ size_t n /* size of memory to compare */ )
This routine compares successive elements from two arrays of unsigned char, beginning at the addresses s1 and s2 (both of size n), until it finds elements that are not equal.
string.h
If all elements are equal, zero. If elements differ and the differing element from s1 is greater than the element from s2, the routine returns a positive number; otherwise, it returns a negative number.
memcpy( ) - copy memory from one location to another (ANSI)
void * memcpy ( void * destination, /* destination of copy */ const void * source, /* source of copy */ size_t size /* size of memory to copy */ )
This routine copies size characters from the object pointed to by source into the object pointed to by destination. If copying takes place between objects that overlap, the behavior is undefined.
string.h
A pointer to destination.
memmove( ) - copy memory from one location to another (ANSI)
void * memmove ( void * destination, /* destination of copy */ const void * source, /* source of copy */ size_t size /* size of memory to copy */ )
This routine copies size characters from the memory location source to the location destination. It ensures that the memory is not corrupted even if source and destination overlap.
string.h
A pointer to destination.
memset( ) - set a block of memory (ANSI)
void * memset ( void * m, /* block of memory */ int c, /* character to store */ size_t size /* size of memory */ )
This routine stores c converted to an unsigned char in each of the elements of the array of unsigned char beginning at m, with size size.
string.h
A pointer to m.
strcat( ) - concatenate one string to another (ANSI)
char * strcat ( char * destination, /* string to be appended to */ const char * append /* string to append to destination */ )
This routine appends a copy of string append to the end of string destination. The resulting string is null-terminated.
string.h
A pointer to destination.
strchr( ) - find the first occurrence of a character in a string (ANSI)
char * strchr ( const char * s, /* string in which to search */ int c /* character to find in string */ )
This routine finds the first occurrence of character c in string s. The terminating null is considered to be part of the string.
string.h
The address of the located character, or NULL if the character is not found.
strcmp( ) - compare two strings lexicographically (ANSI)
int strcmp ( const char * s1, /* string to compare */ const char * s2 /* string to compare s1 to */ )
This routine compares string s1 to string s2 lexicographically.
string.h
An integer greater than, equal to, or less than 0, according to whether s1 is lexicographically greater than, equal to, or less than s2, respectively.
strcoll( ) - compare two strings as appropriate to LC_COLLATE (ANSI)
int strcoll ( const char * s1, /* string 1 */ const char * s2 /* string 2 */ )
This routine compares two strings, both interpreted as appropriate to the LC_COLLATE category of the current locale.
string.h
An integer greater than, equal to, or less than zero, according to whether string s1 is greater than, equal to, or less than string s2 when both are interpreted as appropriate to the current locale.
strcpy( ) - copy one string to another (ANSI)
char * strcpy ( char * s1, /* string to copy to */ const char * s2 /* string to copy from */ )
This routine copies string s2 (including EOS) to string s1.
string.h
A pointer to s1.
strcspn( ) - return the string length up to the first character from a given set (ANSI)
size_t strcspn ( const char * s1, /* string to search */ const char * s2 /* set of characters to look for in s1 */ )
This routine computes the length of the maximum initial segment of string s1 that consists entirely of characters not included in string s2.
string.h
The length of the string segment.
ansiString, strpbrk( ), strspn( )
strerror_r( ) - map an error number to an error string (POSIX)
STATUS strerror_r ( int errcode, /* error code */ char * buffer /* string buffer */ )
This routine maps the error number in errcode to an error message string. It stores the error string in buffer.
This routine is the POSIX reentrant version of strerror( ).
string.h
OK or ERROR.
ansiString, strerror( )
strerror( ) - map an error number to an error string (ANSI)
char * strerror ( int errcode /* error code */ )
This routine maps the error number in errcode to an error message string. It returns a pointer to a static buffer that holds the error string.
This routine is not reentrant. For a reentrant version, see strerror_r( ).
string.h
A pointer to the buffer that holds the error string.
ansiString, strerror_r( )
strlen( ) - determine the length of a string (ANSI)
size_t strlen ( const char * s /* string */ )
This routine returns the number of characters in s, not including EOS.
string.h
The number of non-null characters in the string.
strncat( ) - concatenate characters from one string to another (ANSI)
char * strncat ( char * dst, /* string to append to */ const char * src, /* string to append */ size_t n /* max no. of characters to append */ )
This routine appends up to n characters from string src to the end of string dst.
string.h
A pointer to the null-terminated string s1.
strncmp( ) - compare the first n characters of two strings (ANSI)
int strncmp ( const char * s1, /* string to compare */ const char * s2, /* string to compare s1 to */ size_t n /* max no. of characters to compare */ )
This routine compares up to n characters of string s1 to string s2 lexicographically.
string.h
An integer greater than, equal to, or less than 0, according to whether s1 is lexicographically greater than, equal to, or less than s2, respectively.
strncpy( ) - copy characters from one string to another (ANSI)
char *strncpy ( char * s1, /* string to copy to */ const char * s2, /* string to copy from */ size_t n /* max no. of characters to copy */ )
This routine copies n characters from string s2 to string s1. If n is greater than the length of s2, nulls are added to s1. If n is less than or equal to the length of s2, the target string will not be null-terminated.
string.h
A pointer to s1.
strpbrk( ) - find the first occurrence in a string of a character from a given set (ANSI)
char * strpbrk ( const char * s1, /* string to search */ const char * s2 /* set of characters to look for in s1 */ )
This routine locates the first occurrence in string s1 of any character from string s2.
string.h
A pointer to the character found in s1, or NULL if no character from s2 occurs in s1.
ansiString, strcspn( )
strrchr( ) - find the last occurrence of a character in a string (ANSI)
char * strrchr ( const char * s, /* string to search */ int c /* character to look for */ )
This routine locates the last occurrence of c in the string pointed to by s. The terminating null is considered to be part of the string.
string.h
A pointer to the last occurrence of the character, or NULL if the character is not found.
strspn( ) - return the string length up to the first character not in a given set (ANSI)
size_t strspn ( const char * s, /* string to search */ const char * sep /* set of characters to look for in s */ )
This routine computes the length of the maximum initial segment of string s that consists entirely of characters from the string sep.
string.h
The length of the string segment.
ansiString, strcspn( )
strstr( ) - find the first occurrence of a substring in a string (ANSI)
char * strstr ( const char * s, /* string to search */ const char * find /* substring to look for */ )
This routine locates the first occurrence in string s of the sequence of characters (excluding the terminating null character) in the string find.
string.h
A pointer to the located substring, or s if find points to a zero-length string, or NULL if the string is not found.
strtok( ) - break down a string into tokens (ANSI)
char * strtok ( char * string, /* string */ const char * separator /* separator indicator */ )
A sequence of calls to this routine breaks the string string into a sequence of tokens, each of which is delimited by a character from the string separator. The first call in the sequence has string as its first argument, and is followed by calls with a null pointer as their first argument. The separator string may be different from call to call.
The first call in the sequence searches string for the first character that is not contained in the current separator string. If the character is not found, there are no tokens in string and strtok( ) returns a null pointer. If the character is found, it is the start of the first token.
strtok( ) then searches from there for a character that is contained in the current separator string. If the character is not found, the current token expands to the end of the string pointed to by string, and subsequent searches for a token will return a null pointer. If the character is found, it is overwritten by a null character, which terminates the current token. strtok( ) saves a pointer to the following character, from which the next search for a token will start. (Note that because the separator character is overwritten by a null character, the input string is modified as a result of this call.)
Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved pointer and behaves as described above.
The implementation behaves as if strtok( ) is called by no library functions.
This routine is not reentrant; the reentrant form is strtok_r( ).
string.h
A pointer to the first character of a token, or a NULL pointer if there is no token.
ansiString, strtok_r( )
strtok_r( ) - break down a string into tokens (reentrant) (POSIX)
char * strtok_r ( char * string, /* string to break into tokens */ const char * separators, /* the separators */ char * * ppLast /* pointer to serve as string index */ )
This routine considers the null-terminated string string as a sequence of zero or more text tokens separated by spans of one or more characters from the separator string separators. The argument ppLast points to a user-provided pointer which in turn points to the position within string at which scanning should begin.
In the first call to this routine, string points to a null-terminated string; separators points to a null-terminated string of separator characters; and ppLast points to a NULL pointer. The function returns a pointer to the first character of the first token, writes a null character into string immediately following the returned token, and updates the pointer to which ppLast points so that it points to the first character following the null written into string. (Note that because the separator character is overwritten by a null character, the input string is modified as a result of this call.)
In subsequent calls string must be a NULL pointer and ppLast must be unchanged so that subsequent calls will move through the string string, returning successive tokens until no tokens remain. The separator string separators may be different from call to call. When no token remains in string, a NULL pointer is returned.
string.h
A pointer to the first character of a token, or a NULL pointer if there is no token.
ansiString, strtok( )
strxfrm( ) - transform up to n characters of s2 into s1 (ANSI)
size_t strxfrm ( char * s1, /* string out */ const char * s2, /* string in */ size_t n /* size of buffer */ )
This routine transforms string s2 and places the resulting string in s1. The transformation is such that if strcmp( ) is applied to two transformed strings, it returns a value greater than, equal to, or less than zero, corresponding to the result of the strcoll( ) function applied to the same two original strings. No more than n characters are placed into the resulting s1, including the terminating null character. If n is zero, s1 is permitted to be a NULL pointer. If copying takes place between objects that overlap, the behavior is undefined.
string.h
The length of the transformed string, not including the terminating null character. If the value is n or more, the contents of s1 are indeterminate.
ansiString, strcmp( ), strcoll( )