/**//* #include <stdlib.h> double atof( const char *str ); 该函数将字符串转换为double类型的数据 该函数还识别e(E)字符 #include <stdlib.h> int atoi( const char *str ); long atol( const char *str ); 这两个函数将字符串转换为int或是long类型的数据 但是这两个函数不识别e(E)的字符 相反的,可以通过sprintf函数将数字转换为字符串类 #include <stdio.h> int sprintf( char *buffer, const char *format, ... ); 该函数基本上同printf函数,只是它将格式化的数据放入buffer中 而不是像printf函数,将格式化后的数据打印大标准输入系统(控制台) 它的返回值为写入的字符串数 printf函数特殊情况下的说明: %c character %d signed integers %i signed integers %e scientific notation, with a lowercase "e" %E scientific notation, with a uppercase "E" %f floating point %g use %e or %f, whichever is shorter %G use %E or %f, whichever is shorter %o octal %s a string of characters %u unsigned integer %x unsigned hexadecimal, with lowercase letters %X unsigned hexadecimal, with uppercase letters %p a pointer %n the argument shall be a pointer to an integer into which is placed the number of characters written so far %% a '%' sign left-justified: %-12.5f default is right-justified to pad 0 in the spaces use 0 before : %012.4d use l or h with %d, %o, %i, %u, %x, %e, %f, %g means the long, double, or short types use # before %g, %f, %e shows to print decimal fraction whether there is or not use # before %x or %o tells to print '0x' or '0' before the hexidecimal number or octal number #include <ctype.h> int isalnum( int ch ); 测试字符ch是否是数字或是字母(a letter of the alphabet) 类似的有: int isalpha( int ch ); //是否为字母 int iscntrl( int ch ); //是否为控制符(control character (between 0 and 0x1F or equal to 0x7F)) int isdigit( int ch ); //是否为数字 int isgraph( int ch ); //是否为可以见的字符,不包括空格(printable character other than a space) int isprint( int ch ); //是否为可以打印的字符,包括空格(a printable character (including a space) int ispunct( int ch ); //是否为打印字符,但不是字母,数字,空格(即可打印的标点符号或是特殊的附号 //(a printing character but neither alphanumeric nor a space) int isspace( int ch ); //测试是否为空格系列(包括空格,tab键等) //(single space, tab, vertical tab, form feed(换页), carriage return(回车), or newline) //(ch == ' '|| ch == ' ' || ch == ' ' || ch==' ' || ch == ' ' || ch == 'v'); int isxdigit( int ch ); //是否为十六进制的数字(A-F, a-f, or 0-9) int isupper( int ch ); //是否为大写字母 int tosupper( int ch ); //返回字符ch的大写形式 int islower( int ch ); //是否为小写字母 int tolower( int ch ); //返回字符ch的小写形式 #include <string.h> void *memchr( const void *buffer, int ch, size_t count ); 该函数寻找ch字符在buffer中的位置,如果没有找到,返回NULL,否则返回指向该字符的指针 由于buffer为void型的,所以该数组可以是任何类型的(基本类型的) 注:count为字节数,可以用sizeof操作符获取 返回buffer #include <string.h> void *memset( void *buffer, int ch, size_t count ); 该函数用于设置buffer中的count字节数的值为ch值 这个函数在初始化buffer中是一个有效的操作 返回buffer #include <string.h> int memcmp( const void *buffer1, const void *buffer2, size_t count ); 这个函数用于比较buffer1和buffer2中前count个字符的值。前者大返回大于1的值,相等返回0值,小于返回小于0的值 #include <string.h> void *memcpy( void *to, const void *from, size_t count ); 复制知道大小(count)的字符从from到to 返回to #include <string.h> void *memmove( void *to, const void *from, size_t count ); 该函数同memcpy,但是可以实现from和to重叠的情况 #include <string.h> char *strcat( char *str1, const char *str2 ); 函数将str2的内容加入str1,并且返回str1 #include <string.h> char *strchr( const char *str, int ch ); 同memchr,找字符ch #include <string.h> int strcmp( const char *str1, const char *str2 ); 同memcmp函数,比较字符串的大小 #include <string.h> char *strcpy( char *to, const char *from ); 同memcpy函数拷贝字符串 注:上诉三个函数的使用mem-的区别是mem-函数是操作内存的,并且可以操作基本上所有的基本类型数据。 它的参数传入的大小也是一字节为单位的 而str-函数只能操作字符串,并且不用传入大小的参数,因为字符串的结尾'