Write your question here.
I am practicing inputing string from the keyboard. I use function getline to get them. However my code seems not working properly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <string>
usingnamespace std;
// struct type person
struct person {
string name;
int age;
string address;
};
int main() {
person ps;
string address;
cout << "The name: "; getline(cin, ps.name);
cout << "The age: "; cin>> ps.age;
cout << "The address: "; getline(cin, ps.address);
cout << "The name is: " << ps.name << endl;
cout << "The age is: " << ps.age << endl;
cout << "The address is: " << ps.address << endl;
}