get line C++
// extract to string
#include <iostream>
#include <string>
int main ()
{
std::string name;
std::cout << "Please, enter your full name: ";
std::getline (std::cin,name);
std::cout << "Hello, " << name << "!\n";
return 0;
}
get line C++
// extract to string
#include <iostream>
#include <string>
int main ()
{
std::string name;
std::cout << "Please, enter your full name: ";
std::getline (std::cin,name);
std::cout << "Hello, " << name << "!\n";
return 0;
}
cin.getline
string z,s;
while (true)
{
cin>>z;
s+=z;
if(cin.peek()=='\n')
break;
}
................................
OR\/
.................................
string s;
getline(cin,s);
cin.getline
cin>>n;
cin.ignore();
cin.getline(cin,string,'\n');
getline vs cin.getline
getline(cin, variable_name, '\n');
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us