Programming in C

(Barry) #1
String Functions 471

char *strerror (n)
Returns the error message associated with error number n.
size_t strcspn (s1, s2)
Counts the maximum number of initial characters in s1that consist of any characters
but those in s2,returning the result.
size_t strlen (s)
Returns the number of characters in s, excluding the null character.
char *strncat (s1, s2, n)
Copies s2to the endof s1until either the null character is reached or ncharacters
have been copied, whichever occurs first. Returns s1.
int strncmp (s1, s2, n)
Performs the same function as strcmp, except that at most ncharacters from the
strings are compared.
char *strncpy (s1, s2, n)
Copies s2to s1until either the null character is reached or ncharacters have been
copied, whichever occurs first. Returns s1.
char *strrchr (s, c)
Searches the string sfor the last occurrence of the character c. If found, a pointer to
the character in sis returned; otherwise, the null pointer is returned.
char *strpbrk (s1, s2)
Locates the first occurrence of any character from s2inside s1,returning a pointer to
it or the null pointer if not found.
size_t strspn (s1, s2)
Counts the maximum number of initial characters in s1that consist only of charac-
ters from s2,returning the result.
char *strstr (s1, s2)
Searches the string s1for the first occurrence of the string s2. If found, a pointer to
the start of where s2is located inside s1is returned; otherwise, if s2is not located
inside s1, the null pointer is returned.
char *strtok (s1, s2)
Breaks the string s1into tokens based on delimiter characters in s2.For the first call,
s1is the string being parsed and s2contains a list of characters that delimit the
tokens.The function places a null character in s1to mark the end of each token as it

21 0672326663 AppB 6/10/04 2:03 PM Page 471

Free download pdf