I have this game skeleton.
Now, as you can see, it is working, but when i choose something first time, i have to type it TWICE to make it work.
It doesn't matter if i choose Status, Score, or Battle, or Flee, the result is the same: i have to type the option once, and type something else, again.

#include <iostream>
using namespace std;

long his_BattleStatus=1, his_Flee=0;

void typed();
void Fight();
void CallStat();
void CallScore();

int main()
{ ////////MAIN function; !!!!!!!!!!
typed(); 
return 0;
} ///////// END main;

void typed()
{//////////TYPED function; !!!!!!!!!!
USHORT typed_choice;
cout <<"[1]Punch the bastard! [2]See your status. [3]See your score."<<endl;
cin   >>typed_choice>> "\n";
switch (typed_choice)
{
	case 1:
	Fight();
break;
	case 2:
	CallStat();
break;
	case 3:
	CallScore();
break;
	default:
cout << "I can't do that, sorry." <<endl;
break;
}
return;
}////////// END typed;

void Fight()
{/////////////////// BEGIN Fight;

do
 {
  //cout << "Starting battle?" <<endl;
  cout << "[His Rez: ;"
	<< " His Nrg: ; "
	<< "His End: ]" <<endl;
  cout<<"[1]Attack again; [2]Run!   (Exit game... Pnelea mea)"<<endl;
  USHORT my_choice;
  cin>> my_choice;
  switch(my_choice)
   {
   case 1:
	cout<< "You punch him." <<endl;
break;
	case 2:
	cout<< "You run away." <<endl;
	his_BattleStatus=0; his_Flee=1;
break;
	default:
	cout<<"What please?";
	Fight();
  }
 } while ( his_BattleStatus!=0 && his_Flee!=1 );
}/////////////////// END Fight;

void Status()
{/////////STATUS function; !!!!!!!!!
   cout  << "\n[Rez: / ;"
	  << " Nrg: / ; "
	   << "End: / ]"<<endl;
return;
}////////// END Status;

void CallStat()
{/////////CallStat function; !!!!!!!!!
cout<< "Showing the status." <<endl;
typed();
return;
}////////// END CallStat;

void CallScore()
{/////////CallStat function; !!!!!!!!!
cout<< "Showing the score." <<endl;
typed();
return;
}////////// END CallScore;

It is working, but i only want to type the first option (the type() option) ONCE.
I don't understand what is wrong...

I don't see the need for "\n" on this line...

cin >>typed_choice>> "\n";

You are right!
It works!
Thank you.

(SOLVED!)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.