Double slash // in paths - can I use single slash?

Marco A. picture Marco A. · Jun 25, 2013 · Viewed 12.7k times · Source

I have a VS template with something like

string mypath = "C:\\custom\\file.jpg";

I'd like to make the C:\custom\ part with a template substitution parameter $userpath$. Is there any way I can avoid using double slashes?

What I'd like to write is:

string mypath = SOMETHING("C:\custom\file.jpg")

that doesn't get escaped with \c and \f and form a valid path. Is it possible?

Answer

David Rodríguez - dribeas picture David Rodríguez - dribeas · Jun 25, 2013

For paths you should be able to use a single forward slash as a separator:

std::string mypath = "c:/custom/file.jpg";