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 | .\" | |
8c41cf3b | 5 | .\" @(#)string.3 6.1 (Berkeley) %G% |
2fe842cb | 6 | .\" |
8c41cf3b | 7 | .TH STRING 3 "" |
2fe842cb KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- string operations | |
11 | .SH SYNOPSIS | |
12 | .nf | |
a0ea9bf5 KM |
13 | .B #include <strings.h> |
14 | .PP | |
2fe842cb KM |
15 | .B char *strcat(s1, s2) |
16 | .B char *s1, *s2; | |
17 | .PP | |
18 | .B char *strncat(s1, s2, n) | |
19 | .B char *s1, *s2; | |
20 | .PP | |
21 | .B strcmp(s1, s2) | |
22 | .B char *s1, *s2; | |
23 | .PP | |
24 | .B strncmp(s1, s2, n) | |
25 | .B char *s1, *s2; | |
26 | .PP | |
27 | .B char *strcpy(s1, s2) | |
28 | .B char *s1, *s2; | |
29 | .PP | |
30 | .B char *strncpy(s1, s2, n) | |
31 | .B char *s1, *s2; | |
32 | .PP | |
33 | .B strlen(s) | |
34 | .B char *s; | |
35 | .PP | |
36 | .B char *index(s, c) | |
37 | .B char *s, c; | |
38 | .PP | |
39 | .B char *rindex(s, c) | |
40 | .B char *s, c; | |
41 | .fi | |
42 | .SH DESCRIPTION | |
43 | These functions operate on null-terminated strings. | |
44 | They do not check for overflow of any receiving string. | |
45 | .PP | |
46 | .I Strcat | |
47 | appends a copy of string | |
48 | .I s2 | |
49 | to the end of string | |
50 | .IR s1 . | |
51 | .I Strncat | |
52 | copies at most | |
53 | .I n | |
a0ea9bf5 | 54 | characters. Both return a pointer to the null-terminated result. |
2fe842cb KM |
55 | .PP |
56 | .I Strcmp | |
57 | compares its arguments and returns an integer | |
a0ea9bf5 | 58 | greater than, equal to, or less than 0, according as |
2fe842cb | 59 | .I s1 |
a0ea9bf5 | 60 | is lexicographically greater than, equal to, or less than |
2fe842cb KM |
61 | .IR s2 . |
62 | .I Strncmp | |
63 | makes the same comparison but looks at at most | |
64 | .I n | |
65 | characters. | |
66 | .PP | |
67 | .I Strcpy | |
68 | copies string | |
69 | .I s2 | |
70 | to | |
71 | .I s1, | |
72 | stopping after the null character has been moved. | |
73 | .I Strncpy | |
74 | copies exactly | |
75 | .I n | |
a0ea9bf5 | 76 | characters, truncating or null-padding |
2fe842cb | 77 | .I s2; |
a0ea9bf5 | 78 | the target may not be null-terminated if the length of |
2fe842cb KM |
79 | .I s2 |
80 | is | |
81 | .I n | |
a0ea9bf5 | 82 | or more. Both return |
2fe842cb KM |
83 | .IR s1 . |
84 | .PP | |
85 | .I Strlen | |
86 | returns the number of non-null characters in | |
87 | .IR s . | |
88 | .PP | |
89 | .I Index | |
90 | .RI ( rindex ) | |
a0ea9bf5 | 91 | returns a pointer to the first (last) occurrence of character |
2fe842cb KM |
92 | .I c |
93 | in string | |
94 | .I s, | |
95 | or zero if | |
96 | .I c | |
97 | does not occur in the string. |