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?
Double Backslashes (\\)Two backslashes are used as a prefix to a server name (hostname). For example, \\a5\c\expenses is the path to the EXPENSES folder on the C: drive on server A5. See UNC, \\, path and forward slash.
Windows ignores double backslashes. So while the second syntax with \ is correct and you should use that one, the first with \\ works too. The only exception is double-backslash at the very beginning of a path that indicates a UNC path.
Python has two division operators, a single slash character for classic division and a double-slash for “floor” division (rounds down to nearest whole number). Classic division means that if the operands are both integers, it will perform floor division, while for floating point numbers, it represents true division.
Windows traditionally uses the backslash ( \ ) to separate directories in file paths. (For example, C:\Program Files\PuppetLabs .)
For paths you should be able to use a single forward slash as a separator:
std::string mypath = "c:/custom/file.jpg";
Try a raw string literal:
string mypath = R"(C:\custom\file.jpg)";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With