ok all I need is to do is put qoits in cout. Like cout<<"She said"this""; or something like that. It is not dissus able I need quotation marks in it. (makeing JavaScript thing from inside program with user imput.) Just tell me how to do it instead of alternative ways of doing it. Unless the only way isnt this.

Recommended Answers

Try the escape sequence \" e.g.

std::cout << "this is a quote \"" << std::endl;
Jump to Post

Same way

Jump to Post

All 5 Replies

Try the escape sequence \" e.g.

std::cout << "this is a quote \"" << std::endl;

Cool man. Now how do I put a plain \ in it.

Same way

Oh yeah will this work in ofstream ?

Oh yeah will this work in ofstream?

Yes. std::ofstream is a std::ostream.

C++11: Just use raw string literals.

std::cout << R"---(The path is "C:\Equation_MinGW\bin\g++.exe". (C++11))---" << '\n' ;

   std::cout << R"(menu
----
   1. one
   2. two
   3. three
   )" ;

See: http://www2.research.att.com/~bs/C++0xFAQ.html#raw-strings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.