Store paragraph of text in variable C++ -


I am trying to write a program that takes the user's input and stores the entire paragraph in a variable . However, if the user enters: "Hello, this is some text." It only gives "hello" anybody can help?

Thank you!

  #include & lt; Iostream & gt; # Include & lt; iomanip & gt; using namespace std; Class GetText {public: string text; Zero user text () {cout & lt; & Lt; "Please type a message:"; Cin & gt; & Gt; Text; } Zero to_string () {cout & lt; & Lt; "\ N" & lt; & Lt; "User text:" & lt; & Lt; "\ N" & lt; & Lt; Text & lt; & Lt; Endl; }}; Int main () {GetText test; test.userText (); Test.to_string (); Return 0; }   

You can use the user to read the entire line from the input: / p>

  std :: string text; Std :: getline (std :: cin, text);   



Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -