getline() C++

//Storing a entire line in a string variable //Giame Fajardo #include <iostream> using namespace std; main(){ string FistName,LastName; cout<<"Digite El Nombre\n";getline(cin,FistName),fflush(stdin); cout<<"Digite El Apellido\n";;getline(cin,LastName),fflush(stdin); cout<<"---------------------------------\n"; cout<<"The firtname is:"<<FistName,cout<<"\n"; cout<<"The lastname is:"<<LastName,cout<<"\n"; cout<<"---------------------------------\n"; }
This snippet shows how to store a entire line in a string variable, by using the getline function.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.