T
T
Ternick2019-03-24 20:00:00
C++ / C#
Ternick, 2019-03-24 20:00:00

How can I make it possible to output string literals?

For example:

#include <string>
string s = "\n"
std::cout<<s<<std::endl;

And the output should be :
\n
How to do that ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-03-24
@Ternick

And the output should be :
\n
How to do that ?

suppose once:
int main()
{
  std::string s = "\\n";
  std::cout << s << std::endl;
}

two:
int main()
{
  auto s = R"(Raw string literal\n)";
  std::cout << s << std::endl;
}

User-defined literals

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question