Skip to content

Instantly share code, notes, and snippets.

@yuk7
Created March 7, 2019 20:40
Show Gist options
  • Save yuk7/6c1aa1253edb73e7f2d1a93c259abf24 to your computer and use it in GitHub Desktop.
Save yuk7/6c1aa1253edb73e7f2d1a93c259abf24 to your computer and use it in GitHub Desktop.
escape_path.c
#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