📄 string.3
字号:
.\" 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.1 (Berkeley) 5/15/85.\".TH STRING 3 "May 15, 1985".UC 4.SH NAMEstring, strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- string operationsstring, strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, strchr, strrchr, strerror, memcmp, memcpy, memmove, memchr, memset, index, rindex \- string operations.SH SYNOPSIS.nf.ft B#include <sys/types.h>#include <strings.h>char *strcat(char *\fIs1\fP, const char *\fIs2\fP)char *strncat(char *\fIs1\fP, const char *\fIs2\fP, size_t \fIn\fP)int strcmp(const char *\fIs1\fP, const char *\fIs2\fP)int strncmp(const char *\fIs1\fP, const char *\fIs2\fP, size_t \fIn\fP)char *strcpy(char *\fIs1\fP, const char *\fIs2\fP)char *strncpy(char *\fIs1\fP, const char *\fIs2\fP, size_t \fIn\fP)size_t strlen(const char *\fIs\fP)char *strchr(const char *\fIs\fP, int \fIc\fP)char *strrchr(const char *\fIs\fP, int \fIc\fP)char *strerror(int \fIerrnum\fP)int memcmp(const void *\fIs1\fP, const void *\fIs2\fP, size_t \fIn\fP)void *memcpy(void *\fIs1\fP, const void *\fIs2\fP, size_t \fIn\fP)void *memmove(void *\fIs1\fP, const void *\fIs2\fP, size_t \fIn\fP)void *memchr(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP)void *memset(void *\fIs\fP, int \fIc\fP, size_t \fIn\fP)char *index(const char *\fIs\fP, int \fIc\fP)char *rindex(const char *\fIs\fP, int \fIc\fP).ft R.fi.SH DESCRIPTIONThese functions operate on null-terminated strings.They do not check for overflow of any receiving string..PP.B Strcatappends a copy of string.I s2to the end of string.IR s1 ..B Strncatcopies at most.I ncharacters. Both return a pointer to the null-terminated result..PP.B Strcmpcompares its arguments and returns an integergreater than, equal to, or less than 0, according as.I s1is lexicographically greater than, equal to, or less than.IR s2 ..B Strncmpmakes the same comparison but looks at at most.I ncharacters..PP.B Strcpycopies string.I s2to.IR s1 ,stopping after the null character has been moved..B Strncpycopies exactly.I ncharacters, truncating or null-padding.I s2;the target may not be null-terminated if the length of.I s2is.I nor more. Both return.IR s1 ..PP.B Strlenreturns the number of non-null characters in.IR s ..PP.B Strchr.RB ( strrchr )returns a pointer to the first (last) occurrence of character .I cin string.I s,or null if.I cdoes not occur in the string..PP.B Strerrorreturns the error string for the system call error.IR errnum .See.BR intro (2)..PP.B Memcmpis like.B strcmpexcept that the strings are memory blocks of length.IR n .Null characters are treated as ordinary characters..PP.B Memcpycopies.I nbytes from the location pointed to by.I s2to.IR s1 ..B Memmoveis like memcpy, except that it can handle overlap between the two strings.Both functions return.IR s1 ..PP.B Memchrreturns a pointer to the first occurrence of character.I cin string.I s,or null if.I cdoes not occur in the string..PP.B Memsetsets.I nbytes to.I cstarting at location.IR s .It returns.IR s ..PP.B Indexand.B rindexare obsolete versions of.B strchrand.BR strrchr .New code should avoid using them..SH NOTESCharacters are compared as.BR "unsigned char" ,whether.B charitself is signed or not.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -