Quote:
Originally posted by jwbarton
In Windows, the directory separator character is defined as the backslash character '\', which (as PaulWendt indicated) in C/C++ can be specified in a literal string as '\\'.
When calling native API functions, you can generally use the forward slash character '/' instead of the backslash character when specifying a path to a file (as Paul McKenzie indicated).
However, sometimes the backslash character is needed due to the input requirements of programs that you are spawning from the current program (or from the command line). Due to choices made early in the days of MSDOS, the forward slash character is often used to specify a program option (instead of using the '-' character). This will sometimes result in programs which are parsing the command line to not interpret the path correctly, but instead to break up the path into a series of nonsense options to the program. For instance, the dir command does not like the forward slash character in paths.
Best regards,
John
You are right. That's why I stated "if possible". You can also add those times when you are getting the filename from a function you have no control over, and the filename may contain backslashes.