Write a program to remove all repeated characters from a given string


Write a program to remove all repeated characters from a given string.
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void main()
  5. {
  6.             char str[100];
  7.             int i, j, k;
  8.  
  9.             printf("Please enter any string :  ");
  10.             gets(str);
  11.                        
  12.             for(i = 0; i < strlen(str); i++) {
  13.                         for(j = i + 1; str[j] != '\0'; j++) {
  14.                                     if(str[j] == str[i]) {
  15.                                                 for(k = j; str[k] != '\0'; k++) {
  16.                                                             str[k] = str[k + 1];
  17.                                                 }
  18.                                     }
  19.                         }
  20.             }
  21.             printf("After removing all repeated characters = %s ", str);
  22. }


একটি মন্তব্য পোস্ট করুন