Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. char* make_name_short(char* name) {
  5. uint8_t i = 1;
  6. uint8_t n = 1;
  7. static char compact_name[250];
  8. compact_name[0] = name[0];
  9.  
  10. while (name[i] != '\0') {
  11.  
  12. if (name[i] != name[i - 1]) {
  13. compact_name[n] = name[i];
  14. n++;
  15. }
  16. i++;
  17. }
  18.  
  19. compact_name[n] = '\0';
  20. return compact_name;
  21. }
  22.  
  23. void main() {
  24. char* name;
  25. name = make_name_short("boooooobapalaxxxxios");
  26. printf("%s", name);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement