Hi, I am working on a fire gun program but I cant seem to get it right. I want it to check if there is efn. ammo for the gun you pick. Will I got this ok, but I cant get this void right for some reason.
It gives me errors on that my int and strings were never declared.Code:#include "tt.h" using namespace std; void gunfire(void); int main() { int gunammopistal; int gunammoshootgun; string whatgun; string gunammouseornot; gunammopistal=15; gunammoshootgun=5; bool pQuit = false; while( false == pQuit ) { cout<<"Press -F- if you want to fire the gun. Press -R- to reload. Also if you want a differnt gun press 1 for pistal and 2 for shoot gun."<<endl; cout<<"You have right now "<<whatgun<<endl; cin >> whatgun; cin >> gunammouseornot; if(whatgun=="1"){ gunfire();} else if(whatgun=="2"){ gunfire();} } } void gunfire() { if(gunammouseornot=="f"){ if(gunammopistal==0||gunammoshootgun==0){ cout<<"Click..."<<endl;} else if(gunammopistal==15||gunammoshootgun==5){ cout<<"Its full."<<endl;} else if(gunammopistal>0||gunammoshootgun>0){ if(whatgun=="1"){ gunammopistal=gunammopistal-1; cout<<"BANG!"<<endl; cout<<"You got "<<gunammopistal<<endl;} else if(whatgun=="2"){ gunammoshootgun=gunammoshootgun-1; cout<<"BANG!"<<endl; cout<<"You got "<<gunammoshootgun<<endl;}}} else if(gunammouseornot=="r"){ if(whatgun=="1"){ gunammopistal=gunammopistal+15; cout<<"Reloading."<<endl; cout<<"You got "<<gunammopistal<<endl;} else if(whatgun=="2"){ gunammoshootgun=gunammoshootgun+5; cout<<"Reloading."<<endl; Sleep(1000); cout<<"."<<endl; Sleep(1000); cout<<"."<<endl; cout<<"You got "<<gunammoshootgun<<endl;} } }