Howdy,
I need to print given path to a file. The problem is that my app is platform independent -> I can get a Win32 style path:

C:\foo\bar.dat

.

The problem is with printing single backslashes '\' -> single char converts to "\char" style. I need to convert it somehow to proper style "\\" in order to print it. I was thinking about some lib function (dir.h, sys_*, etc.), but I had no luck.

Any help appreciated! :)

You can use / in both MS-Windows and *nix. C:/foo/bar.dat

If you still want to use \, then the only time you need \\ is in string literals which are surrounded by quotes. Paths read from a file or returned by some other function do not need \\.

You can use / in both MS-Windows and *nix. C:/foo/bar.dat

If you still want to use \, then the only time you need \\ is in string literals which are surrounded by quotes. Paths read from a file or returned by some other function do not need \\.

Yes, '/' or '\' are both valid.

I completely forgot that "\\" is needed only in string literals... I'm sorry and thank you for your quick response.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.