Ok so I have a file path i got from findfirstfile. I need to replace all the single backslashes with double backslashes correct? What is the best way to do that?
Ok so I have a file path i got from findfirstfile. I need to replace all the single backslashes with double backslashes correct? What is the best way to do that?
Replacing them with forward slashes would be easier. An unoptomized example:
Code:{ char *p; while((p = strchr(path, '\\'))) *p = '/'; }
If you understand what you're doing, you're not learning anything.
No. Escaping backslashes like this is only something you need to do to string literals in source code.Originally Posted by Grunt12
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
oh, so if i am writing it in code, i have to escape it, but if I get the path from an api function I dont.
That is correct. The difference is that the compiler treats backslash as a special character (a character escape), but the runtime environment does not. Paths received from API funcions are not seen by the compiler.
Insert obnoxious but pithy remark here