Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <inttypes.h>
- #include <string.h>
- void normalize_path(char *buf)
- {
- char *ptr = buf;
- int first = 1, flag = 0;
- while (*ptr)
- {
- if (*ptr == '/')
- {
- flag = 1;
- while (*ptr)
- {
- if (*ptr != '/')
- {
- break;
- }
- ptr++;
- }
- }
- if (flag)
- {
- *buf = *ptr;
- buf++;
- }
- else
- {
- buf++;
- }
- ptr++;
- // "a///b///c/d"
- }
- buf++;
- *buf = '\0';
- }
- int main()
- {
- char a[] = "a////b///c/d";
- normalize_path(a);
- printf("%s\n", a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment