为什么n(次数)无法读入(程序显示段错误),如果不加n程序正常运行
题目如下:输入一个正整数 repeat (0
我的代码:
#include
void strmcpy(char *s,char *t,int m)
{
char *p=(t+m-1);
char *ps=s;
while(*p)
{
*ps=*p;
ps++;
p++;
}
*ps='\0';
}
int main()
{
int re;
scanf("%d",re);
char t[111],s[111];
int m;
for(int i=0;ifgets(t,1110,stdin);
scanf("%d",&m);
strmcpy(s,t,m);
printf("%s",s);
system("pause");
}
return 0;
}
scanf("%d",re); 参数这里缺了'&'符,修改: scanf("%d",&re);