[英]The function strcpy doesn't work
I had a homework saying that i should我有作业说我应该
create a program which takes a string and remove all successive repetitions in it.创建一个程序,该程序接受一个字符串并删除其中的所有连续重复项。
i don't know why it doesn't work, this is my code :我不知道为什么它不起作用,这是我的代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
int main()
{
char ch[50];
gets(ch);
int i;
for (i=0;i<strlen(ch)-1;i++);
{
while (ch[i] == ch[i+1])
strcpy(ch+i,ch+i+1);
}
puts(ch);
return 0;
}
Remove the ;去除那个 ; after for loop because it terminates the loop and is wrong.在 for 循环之后,因为它终止了循环并且是错误的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.