Inputting Name

closed account (oy8URXSz)
Hey guys, need some help over here. How would i display the full name I input? Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>
using namespace std;
int main()
{
	char name;
	cout<<"Hi there, what's your name?"<<endl;
	cin>>name;
	system("cls");
	cout<<"Good day "<<name<<endl;
	system("pause");
    return 0;
}


The problem is, it only displays the first letter of the name you inpuut. For instance, I entered "markgreen", it only displays "m". That's all, thanks for reading.
That's because you are only using a char to store the name (that is, a single character). Use an std::string if you want to store more than that.
closed account (oy8URXSz)
yea! Thank you firedraco :D
Topic archived. No new replies allowed.