Commit | Line | Data |
---|---|---|
2fe842cb KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
038307dc | 5 | .\" @(#)string.3 6.5 (Berkeley) %G% |
2fe842cb | 6 | .\" |
8c41cf3b | 7 | .TH STRING 3 "" |
2fe842cb KM |
8 | .UC 4 |
9 | .SH NAME | |
d398dc0e | 10 | strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp, strcpy, |
28fe375c | 11 | strncpy, strlen, index, rindex \- string operations |
2fe842cb KM |
12 | .SH SYNOPSIS |
13 | .nf | |
a0ea9bf5 KM |
14 | .B #include <strings.h> |
15 | .PP | |
038307dc KB |
16 | .B char *strcat(s, append) |
17 | .B char *s, *append; | |
2fe842cb | 18 | .PP |
038307dc KB |
19 | .B char *strncat(s, append, count) |
20 | .B char *s, *append; | |
21 | .B int count; | |
2fe842cb KM |
22 | .PP |
23 | .B strcmp(s1, s2) | |
24 | .B char *s1, *s2; | |
25 | .PP | |
038307dc | 26 | .B strncmp(s1, s2, count) |
2fe842cb | 27 | .B char *s1, *s2; |
038307dc | 28 | .B int count; |
2fe842cb | 29 | .PP |
28fe375c KB |
30 | .B strcasecmp(s1, s2) |
31 | .B char *s1, *s2; | |
32 | .PP | |
038307dc | 33 | .B strncasecmp(s1, s2, count) |
28fe375c | 34 | .B char *s1, *s2; |
038307dc | 35 | .B int count; |
28fe375c | 36 | .PP |
038307dc KB |
37 | .B char *strcpy(to, from) |
38 | .B char *to, *from; | |
2fe842cb | 39 | .PP |
038307dc KB |
40 | .B char *strncpy(to, from, count) |
41 | .B char *to, *from; | |
42 | .B int count; | |
2fe842cb KM |
43 | .PP |
44 | .B strlen(s) | |
45 | .B char *s; | |
46 | .PP | |
47 | .B char *index(s, c) | |
48 | .B char *s, c; | |
49 | .PP | |
50 | .B char *rindex(s, c) | |
51 | .B char *s, c; | |
52 | .fi | |
53 | .SH DESCRIPTION | |
54 | These functions operate on null-terminated strings. | |
55 | They do not check for overflow of any receiving string. | |
56 | .PP | |
038307dc KB |
57 | \fIStrcat\fP appends a copy of string \fIappend\fP to the end of string |
58 | \fIs\fP. \fIStrncat\fP copies at most \fIcount\fP characters. Both | |
59 | return a pointer to the null-terminated result. | |
60 | .PP | |
61 | \fIStrcmp\fP compares its arguments and returns an integer greater than, | |
62 | equal to, or less than 0, according as \fIs1\fP is lexicographically | |
63 | greater than, equal to, or less than \fIs2\fP. \fIStrncmp\fP makes the | |
64 | same comparison but looks at at most \fIcount\fP characters. | |
65 | \fIStrcasecmp\fP and \fIstrncasecmp\fP are identical in function, but are | |
66 | case insensitive. The returned lexicographic difference reflects a | |
67 | conversion to lower-case. | |
68 | .PP | |
69 | \fIStrcpy\fP copies string \fIfrom\fP to \fIto\fP, stopping after the | |
70 | null character has been moved. \fIStrncpy\fP copies exactly \fIcount\fP | |
71 | characters, appending nulls if \fIfrom\fP is less than \fIcount\fP | |
72 | characters in length; the target may not be null-terminated if the | |
73 | length of \fIfrom\fP is \fIcount\fP or more. Both return \fIto\fP. | |
74 | .PP | |
75 | \fIStrlen\fP returns the number of non-null characters in \fIs\fP. | |
2fe842cb KM |
76 | .PP |
77 | .I Index | |
78 | .RI ( rindex ) | |
a0ea9bf5 | 79 | returns a pointer to the first (last) occurrence of character |
fa57e245 KB |
80 | \fIc\fP in string \fIs\fP or zero if \fIc\fP does not occur in |
81 | the string. Setting \fIc\fP to NULL works. |