7-12 字符串复制 (100 分)
编写自定义函数把一个字符串(不超80字符)的内容复制到另一个字符数组中。主函数输入一串字符,复制到另一个数组中输出。
#include
int str_copy(char *d,char *s){
//请在此输入你的代码
}
int main(){
char pa[81];
char pb[81];
gets(pa);
str_copy(pb,pa);
printf("%s",pb);
return 0;
}
输入样例:
#include
结尾无空行
输出样例:
#include
结尾无空行
卡住的地方就是复制过后记得加上’ ’,才表示为字符串
#includeint str_copy(char *d,char *s){ //请在此输入你的代码 while(*s != ' '){ *d = *s; s++; d++; } //注意:此处要加上 符号,才表示为复制字符串否。 *d = ' '; } int main(){ char pa[81]; char pb[18]; gets(pa); str_copy(pb,pa); // printf("%s",pb); puts(pb); return 0; } //#include



