字符串函数<string.h>
strcpy函数
- strcpy()把第二个字符串拷贝到第一个字符串,相当于字符串赋值运算符
- 函数原型 char strcpy(char dest, const char *src)
#include <stdio.h>
#include <string.h>
main()
{
char str1[5]="aa";
char str2[5] = "bb";
//char *str1="aa"; 这样是不行的.
printf("%s ",str1);
printf("%s",strcpy(str1,str2));
}
- 自定义函数
char *fuzhi(char *str1,char *str2)
{
while(*str1)*str1++=*str2++;
}
具体详细内容可以看C Primer Plus 702页B.5.22
2019/12/26 19/18