Help needed to convert path in C

May 31, 2013 at 12:33pm
Hello Friends,
I am writing one module in which i need to convert the path of directory (Windows) but the problem is the path is without '\\' means it is separated with single '\' I have tried to write but unable to code when i put condition for checking '\u' and '\U'. If there is any other predefined library which will convert the normal path into valid C path kindly suggest me.If there are any other way to solve this problem kindly share it with me. Thank you.
May 31, 2013 at 12:45pm
Escape chararacters have any meaning only when they are stored in string literals:
char x[] = "C:\\Hi.txt"
If it stored in file/another strings, escape cheracters are already translated into ASCII characters and you do not need to do anything with them:
1
2
3
4
5
6
7
//file.txt
C:\Hi.txt
//Your code
char y[100];
std::ifstream in(file1.txt);
in.getline(y, 100);
std::ofstream out(y); //We don't need to do anything with y 
May 31, 2013 at 1:16pm
your question is not really very clear, i'm not sure i understood all of it.

here's an example of a string that can represent a file in C++:
C:\\somefolder\\file.txt


Windows requires one back_slash, but C/C++ understands each two back slashes as one, as MiiNiPaa pointed out.

you should return to back slash characters:

http://www.cplusplus.com/doc/tutorial/constants/
Topic archived. No new replies allowed.