I want it to get direction from user, and then add 1 to int xco if the direction was north. I had it semi-working before it would either display zero or some random number. Now it gets the if statement you typ in n and it terminates.
Its making me mad. Then of course there is probably dumb reason it won't work or an if statment won't go there.Code:#include <cstdlib> #include <iostream> #include <ctime> using namespace std; void to() //first territory { cout<<"You can move south or east. type h for help."; } int main(int argc, char *argv[]) { char namen[100]; int initial; int strength; int agility; int defense; char command; char direction; char n; int xco=0; cout<<"What would you like to do?"; cout<<"\n1.New game\n2.Load game\n3.Exit\n"; //Menu cin>>initial; switch(initial){ //menu switch statment case 1: cout<<"Enter your name:"; //ask for name cin>>namen; cout<<namen<<" is it. Alright then\n"; cout<<"Enter your strength agility and defense again(must=20):\n"; cin>>strength>>agility>>defense; while(strength+agility+defense!=20){ //loop if str ag and def not 20 cout<<"Enter strength, agility, and defense(must=20):"; cin>>strength>>agility>>defense; } break; case 2: //loading game cout<<"Not availiable yet"; system("PAUSE"); break; case 3: //exit return 0; break; default: cout<<"error"; //default system("PAUSE"); } //intro cout<<" Welcome to naushmien\n\n*Dramatic Music*\n\n"; to(); for(int loop=0;loop<100;loop++){ //main loop cin>>command; switch(command){ case 'm': //movement cout<<"which way would you like to move?"; cin>>direction; if (direction=n) return xco+1; cout<<xco; //for test break; break; default: cout<<"messed"; break; } } system("PAUSE"); return EXIT_SUCCESS; }



LinkBack URL
About LinkBacks


