Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void normalize_path(char *buf)
  6. {
  7.     for (char* it = buf; *it != '\0'; ++it)
  8.     {
  9.         if (it[0] != '/' || it[0] == '/' && it[1] != '/')
  10.         {
  11.             *buf = *it;
  12.             buf += 1;
  13.         }
  14.     }
  15.     *buf = '\0';
  16. }
  17.  
  18. int main()
  19. {
  20.     const char source[] = "";
  21.     char* s = malloc(sizeof(source) / sizeof(char));
  22.     strcpy(s, source);
  23.     printf("Before:\n%s\n", s);
  24.     normalize_path(s);
  25.     printf("After:\n%s\n", s);
  26.     getchar();
  27.     free(s);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement