Since the very first time I programmed c++ I've been trying to make a program that looks like this
#include <iostream>
using namespace std;
int main()
{
char name;
cout << "please type in your name >> ";
cin >> name;
if(name == 'kevin'){
cout << "hello bitch" << endl;
}
else{
cout << name << ", what a lovely name" << endl;
}
cin.get();
cin.get();
return 0;
}
the only problem is that the char operator only reads the first sign, so if i type in kevin it only output "k, what a lovely name"
if i cange the program to this
#include <iostream>
using namespace std;
int main()
{
char name;
cout << "please type in your name >> ";
cin >> name;
if(name == 'k'){
cout << "hello bitch" << endl;
}
else{
cout << name << ", what a lovely name" << endl;
}
cin.get();
cin.get();
return 0;
}
and then type in k, it will say hello bitch, if I try to change the char name; to char name[30]; I receive a error message saying "[Warning] character constant too long for its type " and "ISO C++ forbids comparison between pointer and integer "
is there any way i can get this thing working?:?: