Created
March 7, 2019 20:40
-
-
Save yuk7/6c1aa1253edb73e7f2d1a93c259abf24 to your computer and use it in GitHub Desktop.
escape_path.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <wchar.h> | |
int main(int argc, char const *argv[]) | |
{ | |
wchar_t buf[500] = L"C:\\test\\testing\\tester\\test.txt"; | |
wchar_t buf2[500] = L""; | |
wchar_t *p = buf; | |
wchar_t *p2; | |
while((p2 = wcschr(p,'\\'))!=NULL) | |
{ | |
*p2=L'\0'; | |
wcscat(buf2,p); | |
wcscat(buf2,L"\\\\"); | |
p=p2+1; | |
} | |
wcscat(buf2,p); | |
wprintf(buf2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment