I'm having problem w/ this codes in bright red, when i'm trying to enter a name the first two letters are always not shown or when inside the inner looping, it don't show what the inner looping is containing.
#include <iostream>
#include <iomanip>
#include <cstdio> // used for reading arrays w/ white spaces or "space'. using gets()using namespace std;
int main()
{
char name[80];// declares an array to hold 50 character strings
int y,x,a, b;
x=3;
while(x=3)
{
cout<<"\t main menu\n";
cout<<"[1] Play game\n";
cout<<"[2] Program Objectives\n";
cout<<"[3] Top score\n";
cout<<"[4] Quit\n";
cout<< "enter the # of choice";
cin>>y;
cin.ignore();
cin.ignore();
system("cls");
switch(y)
{
case 1:
y=1;
x=3;
break;
case 2:
y=2;
x=3;
break;
case 3:
y=3;
x=3;
break;
case 4:
y=4;
x=4;
break;
}
if(y==1)
{
cout<<"\t main menu\n";
cout<<"[1] Play game\n";
cout<<"[2] back\n";
cout<< "enter the # of choice";
cin>>a;
cout<<"input your name: ";
gets(name);// here is the gets()
cin.ignore();
cin.ignore();
system("cls");
switch(a)
{
case 1:
a=1;
y=1;
break;
case 2:
a=2;
x=3;
break;
}
if(a==1)
{
cout<<"\t main menu\n";
cout<<"[1] 1-10\n";
cout<<"[2]1-15\n";
cout<<"[3]1-20n";
cout<< "enter the # of choice";
cin>>b;
switch(b)
{
case 1:
b=1;
y=1;
break;
case 2:
b=2;
y=1;
break;
case 3:
b=3;
y=1;
break;
}
if(b==1)
{
cout<<"1-10\n";
cout<<"you choose this";
cin.ignore();
cin.ignore();
system ("cls");
y=1;
}
if(b==2)
{
cout<<"1-15";
cin.ignore();
cin.ignore();
system("cls");
y=1;
}
if(b==3)
{
cout<<"1-20";
cin.ignore();
cin.ignore();
system("cls");
y=1;
}
}
}
if(a==2)
{
cout<<"back to main menu:";
cin.ignore();
cin.ignore();
system("cls");
x=3;
}
}
if(y==2)
{
cout<<"\t\t\t ---------------------\n";
cout<<"\t\t\t Program Objective\n";
cout<<"\t\t\t ---------------------\n\n";
cout<<" The objective of this project is for the proper application of\n";
cout<<"our learned knowledge on C++. In this project we will try to put in all\n";
cout<<"the things taught to us by our professor in lab and lecture, and also \n";
cout<<"for the user to have fun.";
cin.ignore();
cin.ignore();
system("cls");
x=3;
}
if(y==3)
{
cout<<"topscore";
cin.ignore();
cin.ignore();
system("cls");
x=3;
}
if(y==4)
{
cout<<"goodbye";
cin.ignore();
cin.ignore();
x=4;
}
return 0;
}