Answers for "read string with spaces in c++"

C++
1

include spaces while reading strings in cpp

Using getline() will help you.
Example: 

int main()
{
   std::string name, title;

   std::cout << "Enter your name: "; //Name: Robert De Niro
   std::getline(std::cin, name);

   std::cout << "Enter your favourite movie: "; // title: The Irishman
   std::getline(std::cin, title);

   std::cout << name << "'s favourite movie is " << title;
}
Posted by: Guest on March-18-2021
7

how to make string get spaces c++

string s;
getline(cin,s);
Posted by: Guest on June-02-2020
0

store string with spaces c++

std::string str; 
std::getline( std::cin, str);
Posted by: Guest on April-09-2021
0

read string with spaces in c++

#include <string>
string s;
getline(cin, s);
Posted by: Guest on June-08-2021

Code answers related to "read string with spaces in c++"

Browse Popular Code Answers by Language