STRING(3C) UNIX Programmer's Manual STRING(3C) NAME strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, strchr, strrchr, strpbrk, strspn, strcspn, strtok - charac- ter string operations SYNOPSIS char *strcat (s1, s2) char *s1, *s2; char *strncat (s1, s2, n) char *s1, *s2; int n; int strcmp (s1, s2) char *s1, *s2; int strncmp (s1, s2, n) char *s1, *s2; int n; char *strcpy (s1, s2) char *s1, *s2; char *strncpy (s1, s2, n) char *s1, *s2; int n; int strlen (s) char *s; char *strchr (s, c) char *s, c; char *strrchr (s, c) char *s, c; char *strpbrk (s1, s2) char *s1, *s2; int strspn (s1, s2) char *s1, *s2; int strcspn (s1, s2) char *s1, *s2; char *strtok (s1, s2) char *s1, *s2; HP-UX COMPATIBILITY Level: HP-UX/RUN ONLY Origin: System III DESCRIPTION These functions operate on null-terminated strings. They do not check for overflow of any receiving string. _S_t_r_c_a_t appends a copy of string _s_2 to the end of string _s_1. _S_t_r_n_c_a_t copies at most _n characters. It copies less if _s_2 is shorter than _n characters. Both return a pointer to the null-terminated result (the original value of _s_1). _S_t_r_c_m_p compares its arguments and returns an integer greater than, equal to, or less than 0, according as _s_1 is lexico- graphically greater than, equal to, or less than _s_2. (Nil pointers for _s_1 and _s_2 are treated the same as pointers to null strings.) _S_t_r_n_c_m_p makes the same comparison but looks at at most _n characters (_n less than or equal to zero implies equality). Both of these routines use unsigned char for character comparison. _S_t_r_c_p_y copies string _s_2 to _s_1, stopping after the null char- acter has been moved. _S_t_r_n_c_p_y copies exactly _n characters, truncating or null-padding _s_2; the target may not be null- terminated if the length of _s_2 is _n or more. Both return _s_1. Note that _s_t_r_n_c_p_y should not be used to copy _n bytes of an arbitrary structure. If that structure contains a null byte anywhere, _s_t_r_n_c_p_y will terminate the copy when it encounters the null byte, thus returning less than _n bytes. _S_t_r_l_e_n returns the number of non-null characters in _s. (The "length" of a string does not count the null terminator.) _S_t_r_c_h_r (_s_t_r_r_c_h_r) returns a pointer to the first (last) occurrence of character _c (an 8-bit ASCII value) in string _s, or NULL if _c does not occur in the string. The null character terminating a string is considered to be part of the string. _S_t_r_p_b_r_k returns a pointer to the first occurrence in string _s_1 of any character from string _s_2, or NULL if no character from _s_2 exists in _s_1. _S_t_r_s_p_n (_s_t_r_c_s_p_n) returns the length of the initial segment of string _s_1 which consists entirely of characters from (not from) string _s_2. _S_t_r_t_o_k considers the string _s_1 to consist of a sequence of zero or more text tokens separated by spans of one or more characters from the separator string _s_2. The first call (with pointer _s_1 specified) returns a pointer to the first character of the first token, and will have written a NULL character into _s_1 immediately following the returned token. The function keeps track of its position in the string between separate calls, so that subsequent calls (which must be made with the first argument a NULL pointer) will work through the string _s_1 immediately following that token. In this way subsequent calls will work through the string _s_1 until no tokens remain. The separator string _s_2 may be dif- ferent from call to call. When no token remains in _s_1, a NULL is returned. HARDWARE DEPENDENCIES Series 200: _N is limited to the amount of physical memory on the machine. Series 500: _N is limited to about 500 Mbytes. BUGS All string movement is performed character by character starting at the left. Thus overlapping moves toward the left will work as expected, but overlapping moves to the right (i.e. higher addresses) may yield surprises. The copy operations cannot check for overflow of any receiv- ing string. NULL destinations cause errors; NULL sources are treated as zero-length strings.