实现一个字符串拷贝
main.c文件
1 #include <stdio.h> 2 #include "str_cpy.h" 3 4 int main(int argc, const char *argv[]) 5 { 6 char c[128] = {0}; 7 char c1[128]; 8 char *s=c1; 9 scanf("%[^ ]",s); 10 char *p = str_cpy(c,s); 11 12 printf("c[128]从终端考贝的数据是:%s ",c); 13 14 return 0; 15 }
str_cpy.c文件
1 #include "str_cpy.h" 2 3 char *str_cpy(char *s,char *c) 4 { 5 6 char *p = s; 7 char *q; 8 int i=0; 9 for(q=c;*q!='