Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to make string get spaces c++

string s;
getline(cin,s);
Comment

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;
}
Comment

store string with spaces c++

std::string str; 
std::getline( std::cin, str);
Comment

read string with spaces in c++

#include <string>
string s;
getline(cin, s);
Comment

PREVIOUS NEXT
Code Example
Cpp :: convert all strings in vector to lowercase or uppercase c++ 
Cpp :: c++ template 
Cpp :: how to add space in c++ 
Cpp :: char to int in c++ 
Cpp :: how to reverse a vector in c++ 
Cpp :: Finding square root without using sqrt function? 
Cpp :: iostream c++ 
Cpp :: opencv c++ feature detection 
Cpp :: c++ variable types 
Cpp :: toString method in c++ using sstream 
Cpp :: find positive number factorial in C++ 
Cpp :: fill vector with zeros c++ 
Cpp :: sum of first 100 natural numbers 
Cpp :: constrain function in arduino 
Cpp :: c++ delay 
Cpp :: c++ map lookup 
Cpp :: c++ set intersection 
Cpp :: volumeof a sphere 
Cpp :: c++ compare type 
Cpp :: if else in c++ 
Cpp :: casting to a double in c++ 
Cpp :: __builtin_popcount 
Cpp :: use set to get duplicates in c++ 
Cpp :: cpp custom exception 
Cpp :: A Program to check if strings are rotations of each other or not 
Cpp :: c++ structs 
Cpp :: remove duplicates from sorted list solution in c++ 
Cpp :: qt c++ qdockwidget remove title 
Cpp :: crud with template c++ 
Cpp :: parking charge system project c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =