.\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)string.3 6.5 (Berkeley) 10/22/87 .\" .TH STRING 3 "October 22, 1987" .UC 4 .SH NAME strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp, strcpy, strncpy, strlen, index, rindex \- string operations .SH SYNOPSIS .nf .B #include .PP .B char *strcat(s, append) .B char *s, *append; .PP .B char *strncat(s, append, count) .B char *s, *append; .B int count; .PP .B strcmp(s1, s2) .B char *s1, *s2; .PP .B strncmp(s1, s2, count) .B char *s1, *s2; .B int count; .PP .B strcasecmp(s1, s2) .B char *s1, *s2; .PP .B strncasecmp(s1, s2, count) .B char *s1, *s2; .B int count; .PP .B char *strcpy(to, from) .B char *to, *from; .PP .B char *strncpy(to, from, count) .B char *to, *from; .B int count; .PP .B strlen(s) .B char *s; .PP .B char *index(s, c) .B char *s, c; .PP .B char *rindex(s, c) .B char *s, c; .fi .SH DESCRIPTION These functions operate on null-terminated strings. They do not check for overflow of any receiving string. .PP \fIStrcat\fP appends a copy of string \fIappend\fP to the end of string \fIs\fP. \fIStrncat\fP copies at most \fIcount\fP characters. Both return a pointer to the null-terminated result. .PP \fIStrcmp\fP compares its arguments and returns an integer greater than, equal to, or less than 0, according as \fIs1\fP is lexicographically greater than, equal to, or less than \fIs2\fP. \fIStrncmp\fP makes the same comparison but looks at at most \fIcount\fP characters. \fIStrcasecmp\fP and \fIstrncasecmp\fP are identical in function, but are case insensitive. The returned lexicographic difference reflects a conversion to lower-case. .PP \fIStrcpy\fP copies string \fIfrom\fP to \fIto\fP, stopping after the null character has been moved. \fIStrncpy\fP copies exactly \fIcount\fP characters, appending nulls if \fIfrom\fP is less than \fIcount\fP characters in length; the target may not be null-terminated if the length of \fIfrom\fP is \fIcount\fP or more. Both return \fIto\fP. .PP \fIStrlen\fP returns the number of non-null characters in \fIs\fP. .PP .I Index .RI ( rindex ) returns a pointer to the first (last) occurrence of character \fIc\fP in string \fIs\fP or zero if \fIc\fP does not occur in the string. Setting \fIc\fP to NULL works.