#include <stdio.h>
#include <stdint.h>
void remove_duplicates(char *str) {
int idx = 0;
int jdx = 0;
int kdx = 0;
while(str[idx] != '\0') {
char cc = str[idx];
jdx = idx + 1;
while(str[jdx] != '\0') {
if (cc == str[jdx]) {
kdx = jdx;
while(str[kdx] != '\0') {
str[kdx] = str[kdx+1];
kdx++;
}
str[kdx] = '\0';
}
jdx++;
}
idx++;
}
}
int main() {
char str[101];
fgets(str, sizeof(str), stdin);
// Remove newline
uint8_t i = 0;
while (str[i]) {
if (str[i] == '\n') {
str[i] = '\0';
break;
}
i++;
}
remove_duplicates(str);
printf("%s", str);
return 0;
}
Input
programming
Expected Output
progamin