CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <filesystem>
using namespace std;
int main() {
string fileName("tree.png");
cout << fileName << endl; // ok
// weird
string fileName2("c:\\pics\\tree.png");
cout << fileName2 << endl; // weird
/* workarounds */
// use filesystem::path
filesystem::path fileName3("c:\\pics\\tree.png");
cout << fileName3 << endl; // ok but cannot display single \
// use raw string
string fileName4 = R"(c:\\pics\tree.png)";
cout << fileName4 << endl; // ok
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run