Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void normalize_path(char *buf)
- {
- for (char* it = buf; *it != '\0'; ++it)
- {
- if (it[0] != '/' || it[0] == '/' && it[1] != '/')
- {
- *buf = *it;
- buf += 1;
- }
- }
- *buf = '\0';
- }
- int main()
- {
- const char source[] = "";
- char* s = malloc(sizeof(source) / sizeof(char));
- strcpy(s, source);
- printf("Before:\n%s\n", s);
- normalize_path(s);
- printf("After:\n%s\n", s);
- getchar();
- free(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement