How to convert "D:\Documents\delay.txt" to "D:\\Documents\\delay.txt"?
-
Hi all, I'm trying convert "D:\Documents\delay.txt" to "D:\\Documents\\delay.txt". Anybody can help me? Thank so much!
Why? Escaping is handled at compile time, not runtime. But, depending on your platform, most of the string classes have a replace function. MFC: CString string1("D:\\Documents\\delay.txt"); string1.Replace("\\", "\\\\");
- S 50 cups of coffee and you know it's on! A post a day, keeps the white coats away!
-
Why? Escaping is handled at compile time, not runtime. But, depending on your platform, most of the string classes have a replace function. MFC: CString string1("D:\\Documents\\delay.txt"); string1.Replace("\\", "\\\\");
- S 50 cups of coffee and you know it's on! A post a day, keeps the white coats away!
-
char *strFilePath = new char[1024];
strFilePath = "D:\Documents\delay.txt";So, how to replay('\','\\'). I'm used C language.
Try: strcpy(strFilePath, "D:\\Documents\\delay.txt"); You need the double backslashes \\ in your string literal, because \ is the escape character, so the compiler is translating what you wrote as \D and \d. Lookup "C escape sequences" on google.
- S 50 cups of coffee and you know it's on! A post a day, keeps the white coats away!
-
Hi all, I'm trying convert "D:\Documents\delay.txt" to "D:\\Documents\\delay.txt". Anybody can help me? Thank so much!
Hi you can use strchr method in recursive order which will give u the "\" location. you have to just replace it as "\\" I think this is what looking for.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
-
Hi all, I'm trying convert "D:\Documents\delay.txt" to "D:\\Documents\\delay.txt". Anybody can help me? Thank so much!
the good question is "why do you need to do this ?"... I suspect a dark reason which is in fact because you're trying to hack something because you don't actually understand that string escaping is useful only in your source code... if you're getting the string from an external source (input, textbox, open file dialog), the string you get is already good. you need to escape \ into \\ only in your source code, because if you don't, the \ character will try to escape the character next to it, and that's not what you want. you want a single \ in the string, because it is the folder separator character, which must be typed '\\'...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]