简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM