How to defind string and raw string with escape characters in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string s1 = "c++;\tc;\njava;\nphp;\n";

	// Raw string
	string s2 = R"(c++;\tc;\njava;\nphp;\n)";

	cout << s1 << endl;

	cout << s2 << endl;

	return 0;
}

/*
run:

c++;    c;
java;
php;

c++;\tc;\njava;\nphp;\n

*/

 



answered May 7, 2018 by avibootz

Related questions

1 answer 164 views
1 answer 248 views
1 answer 211 views
211 views asked Aug 28, 2016 by avibootz
1 answer 116 views
116 views asked Feb 3, 2022 by avibootz
...