0
How to enter characters in the program?
I was trying to enter some characters and looks like it does not work. so if someone can help me:) #include <iostream> using namespace std; char name; int age; int main ( ) { cout << "Please enter your name" << endl; cin >> name; cout << "Please enter your age" << endl; cin >> age; cout << "Your name is " << name << " and your age is " << age << endl; return 0; } it tells me that the name is 0 and age doesn't ask me and just enters a 0 what am I doing wrong??
1 Answer
+ 2
u assigned name variable to chatacter which is only one letter in order to enter ur whole name specify name as string ex: string name; thts it!!