除了会使用字符串处理函数,还要会编写字符串处理函数
这节课以字符串复制函数为例(strcpy)
把字符串str2[]="efgh"复制到str1[]="abcdefg"
先用字符串处理函数strcpy 再自己编写字符串处理函数
#include "stdio.h" #include <stdio.h>
#include "string.h" #include <string.h>
main () main()
{char str1="abcdefg",str2="efgh"; {char str1[]="abcdefg",
clear (); /*清屏*/ str2[]="efgh";
strcpy (str1,str2); int i;
puts (str1);} for(i=0;str2;i++)
str1[i]=str2[i];str[i]=0;puts(str1);}