、string
h 中的常见函数 1、函数名称: strcpy 函数原型: char* strcpy(char* str1,char* str2); 函数功能: 把 str2 指向的字符串拷贝到 str1 中去 函数返回: 返回 str1,即指向 str1 的指针 参数说明: 所属文件: #include #include int main() { char string[10]; char *str1="abcdefghi"; strcpy(string,str1); printf("the string is:%s\n",string); return 0; 2、函数名称: strcat 函数原型: char* strcat(char * str1,char * str2); 函数功能: 把字符串 str2 接到 str1 后面,str1 最后的'\0'被取消 函数返回: str1 参数说明: 所属文件: #include #include int main() { char buffer[80]; strcpy(buffer,"Hello "); strcat(buffer,"world"); printf("%s\n",buffer); return 0; } 3、函数名称: strcmp 函数原型: int strcmp(char * str1,char * str2); 函数功能: 比较两个字符串 str1,str2
函数返回: str1str2,返回正数
参数说明: 所属文件: #include #include int main() { char *buf1="aaa", *buf2="bbb", *buf3="ccc"; int ptr; ptr=strcmp(buf2, buf1); if(ptr>0) printf("buffe