Debian Codegraph @

yo/iostreams/examples/quoted.cc

raw
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4
5 using namespace std;
6
7 //main
8 int main()
9 {
10 cout << quoted("hello \"world\"") << '\n';
11
12 string str = "hello 'world'";
13 cout << quoted(str, '\'', '%') << '\n';
14
15 cin >> quoted(str); // 1
16 cin.ignore(100, '\n');
17 cout << "1: " << str << '\n';
18
19 cin >> quoted(str, '\''); // 2
20 cin.ignore(100, '\n');
21 cout << "2: " << str << '\n';
22 }
23
24 // input
25 // "hello \"world\""
26 // 'hello \'world\''
27
28 // output:
29 // "hello \"world\""
30 // 'hello %'world%''
31 // 1: hello "world"
32 // 2: hello 'world'
33 //=