If branch when comparing 'yes'

Hi everyone. I'm very very new to programing. I am trying to write a simple program in attempts to test a few things, namely comparing user input text, and the if function. Sadly i'm not understanding either one.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

char USname [10], TBP [5];

	  int main()
  {
		cout << "Hi, What's your name? \n";
	cin >> USname;
	cout << "Hi " << USname << " my name is Navi. It's good to meet you. \n\n";
	cout << "Are you bothered by me being a text based program? \n\n";
	cin >> TBP;

	
		if (TBP == "yes")
		{
			cout << "about time!!!!";
		}
	
		
	  
 }
Last edited on
1.
1
2
3
4
if (TBP == "yes")
{
	cout << "about time!!!!";
}


Should be :
1
2
3
4
5
6
7
8
if (TBP == "yes")
{
	cout << "about time!!!!";
}
else
{
	cout << "you fool!!!!";
}


2.
char USname [10], TBP [5];

Should be :
char USname [100], TBP [50];
3.
cout << "Hi, What's your name? \n";

Should be :
cout << "Hi, What's your name? : ";

4.
cout << "Are you bothered by me being a text based program? \n\n";

Should be :
cout << "Are you bothered by me being a text based program? : ";
Thanks for you help! i figured it out, the problem was i was line 4

instaed of
char USname [10], TBP [5];

i made it
char USname [100];
string TBP;


apparently you can't compare text in a char?
Topic archived. No new replies allowed.