Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm stuck and cunfused. ARR U C++!

Status
Not open for further replies.

bettermanlamia

Programmer
May 19, 2006
2
US
ok. i made a small ...small SMALL msdos program with Visual C++ express (yep a newbie) and all it was, was a whats ur name age and if u like this kind of music or game.
now i figured out the whole press one if u like this or press 2 for no. but i want to make it a says YES FOR YES! and so on. get it?
good.
here's my code.
im really stuck
#include <iostream>
using namespace std;
int main()
{

int number; /* This describes the number int. */
char conversation1[256];
int halo;
char variable = 2;
char option;

cout << "Welcome To the computer talking program.\n";
cout << "This Program is just a beta.\n";
cout << "Press the enter key to begin..";

cin.get();
cout << "\nHello How old are you? ";
cin >> number; /* Now the number "INT" is entered here. and used */

cin.ignore(); /* cin.ignore(); its a ignore feature, that ignores the enter */
/* button when you hit it so it doesn't close the program */

cout << " So your " << number << ".\n";
cout << "\nI'm 24. \n Just got done with college.\n The classes were hard, but it was worth it. ";
cout << "\n Just a few more months and I'll be 25.\n";

cout << "\nSo what's your name? ";

cin.getline ( conversation1, 256, '\n' );

cout << " So your name is " << conversation1 << ".\n";
cout << " My name is Ibanez Bam Mandez.\n You can call me IBM. ^_^\n";
cout << "\nSo how's life been? ";

cin.getline ( conversation1, 256, '\n' );

cout << " Well that's " << conversation1 << ".\n";

cout << "So do you like video games? \n 1 for yes. 2 for no: ";
cin >> option;
if (!strcmp(option, "yes"))
variable = 1;
switch (variable)

{
case 1 :
cout << "Kewl.\n";
cout << "\n Hit enter to continue..";
cin.get();
break;
case 2 :
cout << "Aww.\n";
cout << "\n Hit enter to continue..";
cin.get();
break;
case 0 :
cout << "Okay.\n";
cout << "\n Hit enter to continue..";
cin.get();
break;
}
cin.get();
cout << "\n So have you ever played Halo? ";
cin >> halo;
switch (halo)
{
case 1 :
cout << "Awesome. Me 2.\n I love Halo.";
cin.get();
break;
case 2 :
cout << "Eh ok.\n";
cin.get();
break;
case 0 :
cout <<" Mmmk.\n";
cin.get();
break;

}

cout << "\n Well gtg peace";

cin.get();

}
 
Please use the [tt][ignore]
Code:
[/ignore][/tt]
tags when posting code.

--
 
Code:
cout << "   So your " << number << ".\n";
In this context, you should use "you're" instead of "your".

Code:
if (!strcmp(option, "yes"))
You declared option as a single char, but you're comparing it against "yes". Declare option as a char[4] or higher, or even better, use an STL string instead of char array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top