STRING.3
资源名称:os_source.zip [点击查看]
上传用户:datang2001
上传日期:2007-02-01
资源大小:53269k
文件大小:3k
源码类别:
操作系统开发
开发平台:
C/C++
- ." 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 NAME
- string, strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex - string operations
- string, 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 *fIs1fP, const char *fIs2fP)
- char *strncat(char *fIs1fP, const char *fIs2fP, size_t fInfP)
- int strcmp(const char *fIs1fP, const char *fIs2fP)
- int strncmp(const char *fIs1fP, const char *fIs2fP, size_t fInfP)
- char *strcpy(char *fIs1fP, const char *fIs2fP)
- char *strncpy(char *fIs1fP, const char *fIs2fP, size_t fInfP)
- size_t strlen(const char *fIsfP)
- char *strchr(const char *fIsfP, int fIcfP)
- char *strrchr(const char *fIsfP, int fIcfP)
- char *strerror(int fIerrnumfP)
- int memcmp(const void *fIs1fP, const void *fIs2fP, size_t fInfP)
- void *memcpy(void *fIs1fP, const void *fIs2fP, size_t fInfP)
- void *memmove(void *fIs1fP, const void *fIs2fP, size_t fInfP)
- void *memchr(const void *fIsfP, int fIcfP, size_t fInfP)
- void *memset(void *fIsfP, int fIcfP, size_t fInfP)
- char *index(const char *fIsfP, int fIcfP)
- char *rindex(const char *fIsfP, int fIcfP)
- .ft R
- .fi
- .SH DESCRIPTION
- These functions operate on null-terminated strings.
- They do not check for overflow of any receiving string.
- .PP
- .B Strcat
- appends a copy of string
- .I s2
- to the end of string
- .IR s1 .
- .B Strncat
- copies at most
- .I n
- characters. Both return a pointer to the null-terminated result.
- .PP
- .B Strcmp
- compares its arguments and returns an integer
- greater than, equal to, or less than 0, according as
- .I s1
- is lexicographically greater than, equal to, or less than
- .IR s2 .
- .B Strncmp
- makes the same comparison but looks at at most
- .I n
- characters.
- .PP
- .B Strcpy
- copies string
- .I s2
- to
- .IR s1 ,
- stopping after the null character has been moved.
- .B Strncpy
- copies exactly
- .I n
- characters, truncating or null-padding
- .I s2;
- the target may not be null-terminated if the length of
- .I s2
- is
- .I n
- or more. Both return
- .IR s1 .
- .PP
- .B Strlen
- returns 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 c
- in string
- .I s,
- or null if
- .I c
- does not occur in the string.
- .PP
- .B Strerror
- returns the error string for the system call error
- .IR errnum .
- See
- .BR intro (2).
- .PP
- .B Memcmp
- is like
- .B strcmp
- except that the strings are memory blocks of length
- .IR n .
- Null characters are treated as ordinary characters.
- .PP
- .B Memcpy
- copies
- .I n
- bytes from the location pointed to by
- .I s2
- to
- .IR s1 .
- .B Memmove
- is like memcpy, except that it can handle overlap between the two strings.
- Both functions return
- .IR s1 .
- .PP
- .B Memchr
- returns a pointer to the first occurrence of character
- .I c
- in string
- .I s,
- or null if
- .I c
- does not occur in the string.
- .PP
- .B Memset
- sets
- .I n
- bytes to
- .I c
- starting at location
- .IR s .
- It returns
- .IR s .
- .PP
- .B Index
- and
- .B rindex
- are obsolete versions of
- .B strchr
- and
- .BR strrchr .
- New code should avoid using them.
- .SH NOTES
- Characters are compared as
- .BR "unsigned char" ,
- whether
- .B char
- itself is signed or not.