The function strcpy doesn't work

Ahmed Troudi

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;
}
Kinshuk Lahiri

Remove the ; after for loop because it terminates the loop and is wrong.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related