Hi everyone,
I'm an absolute newbie in C++, please help me to solve this problem. This problem is something related to the getline method.
I write a program to ask for user's age and name. Just for demonstrating some IO operations.
The program cannot get the name. In fact, it doesn't give me opportunity to type.Code:/*IO Example*/ #include <iostream> #include <string> using namespace std; int main() { int age; string name; // cout << "Please enter your age:"; cin >> age; cout << "Your age is: " << age; cout << " so your year of birth is " << 2010 - age << ".\n"; // cout << "Please enter your name: \n"; getline (cin , name); cout << "Hello " << name << " ! What a good day!"; return 0; }
It's so easy with someone but please help me,
Thanks very much!
Nichya