C/C++常用的字符串处理函数
来源:互联网 发布:网络赌球会抓玩家吗 编辑:程序博客网 时间:2024/06/08 02:21
1.strcpy 和 strncpy
char *strcpy( char *strDestination,const char *strSource);
The strcpy function copies strSource, including the terminating null character, to the location specified bystrDestination. No overflow checking is performed when strings are copied or appended. The behavior ofstrcpy is undefined if the source and destination strings overlap
char *strncpy( char *strDest,const char *strSource,size_tcount );
The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length ofstrSource, a null character is not appended automatically to the copied string. Ifcount is greater than the length ofstrSource, the destination string is padded with null characters up to lengthcount. The behavior ofstrncpy is undefined if the source and destination strings overlap.
2.strcat和 strncat
char *strcat( char *strDestination,const char *strSource);
The strcat function appends strSource to strDestination and terminates the resulting string with a null character. The initial character ofstrSource overwrites the terminating null character ofstrDestination. No overflow checking is performed when strings are copied or appended. The behavior ofstrcat is undefined if the source and destination strings overlap.
char *strncat( char *strDest,const char *strSource,size_tcount );
The strncat function appends, at most, the first count characters ofstrSource tostrDest. The initial character ofstrSource overwrites the terminating null character ofstrDest. If a null character appears instrSource before count characters are appended,strncat appends all characters fromstrSource, up to the null character. Ifcount is greater than the length ofstrSource, the length of strSource is used in place of count. The resulting string is terminated with a null character. If copying takes place between strings that overlap, the behavior is uned.
3.strlen
size_t strlen( const char *string );
Each of these functions returns the number of characters in string, excluding the terminalNULL. No return value is reserved to indicate an error.
4.sprintf 和 _snprintf
int sprintf( char *buffer,const char *format [,argument] ...);
sprintf returns the number of bytes stored in buffer, not counting the terminating null character.
The sprintf function formats and stores a series of characters and values inbuffer. Eachargument (if any) is converted and output according to the corresponding format specification informat. The format consists of ordinary characters and has the same form and function as theformat argument forprintf. A null character is appended after the last character written. If copying occurs between strings that overlap, the behavior is undefined.
int _snprintf( char *buffer,size_tcount,const char *format [,argument] ... );
The _snprintf function formats and stores count or fewer characters and values (including a terminating null character that is always appended unless count is zero or the formatted string length is greater than or equal to count characters) in buffer. Each argument (if any) is converted and output according to the corresponding format specification informat. The format consists of ordinary characters and has the same form and function as theformat argument forprintf. If copying occurs between strings that overlap, the behavior is undefined.
5.sscanf
int sscanf( const char *buffer, const char *format [,argument ] ...);
The sscanf function reads data from buffer into the location given by eachargument. Every argument must be a pointer to a variable with a type that corresponds to a type specifier informat. Theformat argument controls the interpretation of the input fields and has the same form and function as theformat argument for thescanf function; seescanf for a complete description offormat. If copying takes place between strings that overlap, the behavior is undefined.
6.fscanf
int fscanf( FILE *stream,const char *format [,argument ]... );
Return Values
Each of these functions returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. If an error occurs, or if the end of the file stream is reached before the first conversion, the return value is EOF forfscanf andfwscanf.
Remarks
The fscanf function reads data from the current position of stream into the locations given by argument (if any). Each argument must be a pointer to a variable of a type that corresponds to a type specifier in format. format controls the interpretation of the input fields and has the same form and function as the format argument forscanf; seescanf for a description of format. If copying takes place between strings that overlap, the behavior is undefined.
- C/C++常用的字符串处理函数
- C字符串常用处理函数
- C字符串常用处理函数
- C常用字符串处理函数
- c常用字符串处理函数
- C语言字符串处理的几个常用函数
- C语言中常用的几个字符串处理函数:
- c语言中常用的字符串处理函数
- c语言中常用的字符串处理函数
- C语言学习笔记之常用的字符串处理函数
- C语言中常用的字符串处理函数
- C语言常用的字符串处理函数详解!!!!!!!
- C中常用的字符、字符串处理函数
- linux c常用字符串处理函数( 1 )
- linux c常用字符串处理函数( 2 )
- C语言常用字符串处理函数
- C字符串处理常用函数总结
- linux c常用字符串处理函数
- Linux内核源码分析方法
- NYOJ138 找球号2(续)
- 最新ssh框架连接sql server 2008数据库的一些列问题
- 函数指针和指针函数
- shell中(())双括号运算符
- C/C++常用的字符串处理函数
- WCF服务(一)“配置服务引用”对话框
- C++和Objective-C混编(官方文档翻译)
- 行为型模式之中介者模式、调停者模式(Mediator)
- HDU2077:汉诺塔IV
- 输出100以内的完数
- Makefile:13: *** missing separator. Stop.
- 逝去的本命年
- enterprise architect 连接mysql odbc