forsyth20121205-174063a80cc13 years agoHistory
170 lines · 2.7 KB · Text
RawDownload
.TH STRCAT 10.2.SH NAMEstrcat, strcmp, strncmp, strcpy, strncpy, strlen, strchr, strrchr, strdup, strstr \- string operations.SH SYNOPSIS.ta \w'\fLchar* \fP'u.Bchar*	strcat(char *s1, char *s2).PP.Bint	strcmp(char *s1, char *s2).PP.Bint	strncmp(char *s1, char *s2, long n).PP.Bchar*	strcpy(char *s1, char *s2).PP.Bchar*	strncpy(char *s1, char *s2, long n).PP.Blong	strlen(char *s).PP.Bchar*	strchr(char *s, char c).PP.Bchar*	strrchr(char *s, char c).PP.Bchar*	strdup(char *s).PP.Bchar*	strstr(char *s1, char *s2).SH DESCRIPTIONThe arguments.I s1, s2and.I spoint to null-terminated strings.The functions.IR strcat ,.IR strcpy ,and.I strncpyall alter.IR s1 .These functions do not check for overflow ofthe array pointed to by.IR s1 ..PP.I Strcatappends a copy of string.I s2to the end of string.IR s1 ,andreturns a pointer to the null-terminated result..PP.I Strcmpcompares its arguments and returns an integerless than, equal to, or greater than 0,according as.I s1is lexicographically less than, equal to, orgreater than.IR s2 ..I Strncmpmakes the same comparison but examines at most.I nbytes.The comparisons are made with unsigned bytes..PP.I Strcpycopies string.I s2to.IR s1 ,stopping after the null byte has been copied..I Strncpycopies exactly.I nbytes,truncating.I s2or addingnull bytes to.I s1if necessary.The result will not be null-terminated if the lengthof.I s2is.I nor more.Each function returns.IR s1 ..PP.I Strlenreturns the number of bytes in.IR s ,not including the terminating null byte..PP.I Strchr.RI ( strrchr )returns a pointer to the first (last)occurrence of byte.I cin string.IR s ,or.L 0if.I cdoes not occur in the string.The null byte terminating a string is considered tobe part of the string..PP.I Strdupreturns a pointer to a distinct copy of the null-terminated string.I sin space obtained from.IR malloc (10.2)or.L 0if no space can be obtained..PP.I Strstrreturns a pointer to the first occurrence of.I s2as a substring of.IR s1 ,or 0 if there is none.If.I s2is the null string,.I strstrreturns.IR s1 ..SH SOURCE.B /libkern/str*.c.br.B /libkern/str*-\fIobjtype\fP.c.br.B /lib9/strdup.c.SH SEE ALSO.IR memory (10.2),.IR rune (10.2).SH BUGSThese routines know nothing about.SM UTF.Use the routines in.IR rune (10.2)as appropriate.Note, however, that the definition of UTF guarantees that.I strcmpcompares UTF strings correctly..PPThe outcome of overlapping moves varies among implementations..PPNote the absence of ANSI C's.IR strncat ,.IR strpbrk ,.IR strspn ,.IR strcspnand.IR strtok ,but the presence of.IR strdup ....strtod.c strtol.c strtoul.c strtoll.c