以下代码哪儿有问题哦?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void stringcpy3(char s[],char sc[]){
int i=1;
while(*s){
*sc=*s;
if(i%4==0) *(sc++)=' ';
sc++;
s++;
i++;
}
*sc='\0';
}
int main(int argc, char const *argv[])
{
char str[88];
char strc[88];
gets(str);
stringcpy3(str,strc);
puts(strc);
system("pause");
return 0;
}
下面的程序代码已经修改完成,主要是复制函数的那一部分做的修改,请注意对比代码的修改地方。
#include
#include
#include
void stringcpy3(char s[],char sc[])
{ int i=0;
while(*s)
{ if(i&&i%3==0) *(sc++)=' ';
*sc++=*s++;
i++;
}
*sc='\0';
}
int main(int argc, char const *argv[])
{ char str[88];
char strc[88];
gets(str);
stringcpy3(str,strc);
puts(strc);
system("pause");
return 0;
}