Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

getline in c++


#include<bits/stdc++.h>
using namespace std;
#define e  "
"

int main()
{
    string food, name;
    int age;

    getline(cin,name);// for space
    cin>>age;
    cin.ignore();// to ignore the newline character
    getline(cin,food);
    cout<<name<<" "<<age<<" "<<food<<e;

    return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #getline
ADD COMMENT
Topic
Name
8+3 =