C program to remove all repeated characters in the entered string using a while a loop. | सी प्रोग्राम एक लूप का उपयोग करते हुए दर्ज स्ट्रिंग में सभी दोहराया पात्रों को हटाने के लिए।












C program to remove all repeated characters in the entered string using a while a loop.




C program to remove all repeated characters in the entered string using a while a loop.



#include <stdio.h> #include <string.h> #define MAX 100 void removeD(char * text); void removeA(char * text, const char remove, int index); int main() { char text[MAX]; printf("\n Enter any string: "); gets(text); printf("\n Enter String before removing duplicates: %s", text); removeD(text); printf("\n Enter String after removing duplicates: %s", text); return 0; } void removeD(char * text) { int i = 0; while(text[i] != '\0') { removeA(text, text[i], i + 1); i++; } } void removeA(char * text, const char remove, int index) { int i; while(text[index] != '\0') { if(text[index] == remove) { i = index; while(text[i] != '\0') { text[i] = text[i + 1]; i++; } } index++; } }

Output:
Enter any string: c program coding dot com Enter String before removing duplicates: c program coding dot com Enter String after removing duplicates: c progamdint


Exercise: 1
C program to remove all repeated characters in a string.