#include <stdio.h>
#include <stdint.h>
#define DUPLICATE_MARK '\x1b'
void remove_duplicates(char *str) {
char *wr = str;
char *rd = str;
uint8_t unique_symbols[256] = {0};
while (*rd != '\0') {
if (!unique_symbols[(uint8_t)*rd]) {
unique_symbols[(uint8_t)*rd] = 1;
*wr = *rd;
++wr;
}
++rd;
}
*wr = '\0';
}
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