fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char* delete_doubles(const char *input)
  5. {
  6. //create a result string
  7. static char dresult[128];
  8. memset(dresult, 0, sizeof(dresult));
  9.  
  10. int i, result_pos = 0;
  11.  
  12. //create a for loop that handles every single sign of input
  13. for(i = 0; i < strlen(input); i++)
  14. {
  15. //if the result string does not contain the current sign yet
  16. if(strchr(dresult, input[i]) == NULL)
  17. {
  18. //add the current sign to the result
  19. dresult[result_pos] = input[i];
  20. result_pos++;
  21. }
  22. //end of for loop
  23. }
  24.  
  25. //return result
  26. return dresult;
  27. }
  28.  
  29. int main()
  30. {
  31. printf("1: %s\n", delete_doubles("cool-umbrella"));
  32. printf("2: %s\n", delete_doubles("Alle Meine Entchen"));
  33. printf("3: %s\n", delete_doubles("Ich gehe eine Strasse entlang"));
  34. printf("4: %s\n", delete_doubles("aaaaaaabbbccccddddeeeffgggghhhhaaaaabbbdddddjjjjlllkkii1222 3323jjjppppoooaaabb"));
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.02s 1676KB
stdin
Standard input is empty
stdout
1: col-umbrea
2: Ale MinEtch
3: Ich geinStrasl
4: abcdefghjlki12 3po