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