removing all repeated characters from string in c
问题 I want to remove all the repeated characters from a string. For example, if I have: "abcdabef" I want the result to be "cdef" I have tried with loops, but it's getting me confusing. Can anyone just tell me how to do this? Here's what I've tried so far: #include<stdio.h> #include<string.h> main() { char s[20],ch,*p; int i,j,k,cnt; puts("enter string:"); gets(s); for(i=0;s[i];i++) { ch=s[i]; for(cnt=0,j=0;s[j];j++) { if(ch==s[j]) cnt++; if(cnt>1) { for(k=0;s[k]==ch;k++) { strcpy(s+k,s+k+1); if