How to turn backslash to forward slash in Windows environmental variable?

I necessarily need to change backslash to forward slash in windows environmental variable. Do you have any suggestions how can I get %programdata% path with forward slash after systemDrive?

1
2
3
TCHAR path[_MAX_PATH];
    _tcscpy(path, programdata);
    _tcscat(path, _T("\\myfile.txt"));
Last edited on
Do you ever bother to do internet searches before you ask your questions?

https://www.tenforums.com/tutorials/121855-edit-user-system-environment-variables-windows.html

How to do it programmatically, I leave that up to you to surf the 'net for some code.
Thank you, I found a way. Not very comfortable though.

1
2
3
4
Solved:
TCHAR path[_MAX_PATH];
    _tcscpy(path, systemdrive);
    _tcscat(path, _T("/programdata"));
No, it's not a solution because programdata is not always the system drive subfolder:(
Last edited on
Solved:
1
2
3
typedef std::basic_string<TCHAR> tstring;
 tstring pathbasic = tstring(programdata) + _T("\\myfile.txt");
 std::replace(pathbasic.begin(), pathbasic.end(), _T('\\'), _T('/')); 
Last edited on
Of course it's solved, you spammed the same question on at least 3 forums.
Registered users can post here. Sign in or register to post.