The string Library Functions

NAME

cc2str, getword, str_fmt, str2cc, strbalp, strbequ, strcat, strccat, strchr, strcmp, strcpy, strcspn, strdchr, strdup, strempty, strequ, strichr, striequ, stristr, strlen, strmerge, strncat, strncmp, strncpy, strnwrd, strpat, strpbrk, strposn, strrchr, strrpset, strrrot, strrset, strset, strsort, strspn, strstr, strtok, strtoupper, strrpstr, and toupper.

SYNOPSIS

#include <string.h>

char *cc2str (char *p, char c)
char *getword (char *dst, char *p)
str_fmt (char *p, int size,char *fmt)
int str2cc (char *p)
char *strbalp (char *p)
int strbequ (char *s1, char *s2)
char *strcat (char *dst, char *src)
char *strccat (char *dst, char c)
char *strchr (char *p, char c)
int strcmp (char *s1, char *s2)
char *strcpy (char *dst, char *src)
int strcspn (char *p, char *s)
char *strdchr (const char *p)
char *strdup (const char *s)
int strempty (const char *p)
int strequ (const char *s1, const char *s2)
char *strichr (const char *p, const char c)
int striequ (const char *s1, const char *s2)
stristr (const char *dst, const char *p)
int strlen (char *p)
void strmerge (char *d, char *s)
char *strncat (char *dst, char *src, int n)
int strncmp (const char *s1, const char *s2, int n)
char *strncpy (char *dst, char *src, int n)
int strnwrd (char *p)
int strpat (char *p, char *pat)
char *strpbrk (char *s1, char *s2)
char *strposn (char *p, char *q)
char *strrchr (const char *p, char c)
char *strrpset (char *p, char *set)
char *strrpstr (char *p, char *pat)
char *strrrot (char *p)
char *strrset (char *p, char *set)
char *strset (char *p, char *set)
void strsort (char *p)
size_t strspn (const char *s1, const char *s2)
char *strstr (const char *s1, const char *s2)
char *strtok (char *s1, const char *s2)
char *strtoupper (char *p)
int toupper (int c)
where:

c is a character.
dst is the destination string.
fmt is a format to apply to the string.
n is an integer indicating the number of characters to concatenate or copy.
p is a pointer to a string.
pat is a sequence of string characters used in search and replace operations.
q is a pointer to a location in the string pointed to by p.
s1 is the first string in comparison operations.
s2 is the second string in comparison operations.
set is a character to which all characters are set in string p by strset.
size is the string size.
src is the source string.

Note that strmerge and strsort do not explicitly declare void returns and may generate compiler warnings if the programmer uses void return declarations for them.

Functional Description

These functions have the same functions as the C library function of the same name, with the exception of the strncpy routine, which always terminates the resulting string with a null character.

The following #define declarations are the possible values for the fmt argument in the str_fmt function.

#define FMT_RJUST 0 Right justifies the string.
#define FMT_LJUST 1 Left justifies the string.
#define FMT_RJUST0 2 Right justifies the string and fills null spaces in the string with zeros.
#define FMT_CENTER 3 Centers the string.

The following list shows the operations that the string functions perform. The string functions are in alphabetical order.

cc2str converts a control character to a string and returns the result in the string p.
getword copies the next word from the string p into dst, or else returns zero if not found.
str_fmt formats the string p in a field size and format fmt.
str2cc converts the string p into a control character.
strbalp returns a pointer to a balancing parenthesis in a string p.
strbequ returns one if s2 matches first part of s1.
strcat concatenates string src to string dst.
strccat concatenates character char to string dst.
strchr returns a pointer to the character c in the string p, or else returns NULL if the character c is not found.
strcmp returns "+1" if string s1 is more than string s2, "-1" if string s2 is more than s1, or "0" if string s1 is equivalent to string s2.
strcpy copies string src to string dst.
strcspn returns the number of consecutive characters in string p that are not in string s.
strdchr deletes the first character in the string p.
strdup returns a pointer to a duplicate copy of string.
strempty returns one if the string p contains nothing but isspace.
strequ returns one if string s1 matches string s2, else returns zero if not found. Case is not ignored.
strichr inserts character c as the first character in the string p.
striequ returns one if string s1 matches string s2, else returns zero if not found. Case is ignored.
stristr inserts the string p at the beginning of string dst.
strlen returns the length of the string p.
strmerge inserts characters from string s into blank spaces in string d unless string s contains blank characters.
strncat concatenates n characters from string src to string dst.
strncmp makes an unsigned comparison between a specific number of characters in two strings.
strncpy copies n characters from string src to string dst.
strnwrd returns a count of the words in the string p.
strpat returns one if pat matches the string p, else returns zero. The strpat function supports the wildcards ? and *.
strpbrk returns a pointer to the first character in string s2, which is within string s1.
strposn returns a pointer to q in the string p, else returns zero if not found.
strrchr returns a pointer to the last character in string p.
strrpset returns a pointer to the last character in a set of characters within a string, ignoring inner parentheses.
strrpstr like strrpset except that it looks for a single value.
strrrot rotates all characters in string p one character to the right and returns a pointer to the last character in the string.
strrset returns a pointer to the last character in the set of characters within string p.
strset returns a pointer to the first character from SET in the string p.
strsort sorts characters in string p in numeric order.
strspn returns the number of characters in the first consecutive string of characters in s1 that consist entirely of characters in s2.
strstr returns a pointer to the element in s1 where the substring s2 begins.
strtok defines a string as a series of tokens separated by spans of one or more characters of type s2, and returns a pointer to the next token in s1.
strtoupper converts the string p to upper case.
toupper translates c to upper case.


Navigation: Document Home | Document Contents | Document Index