Text game problems

Hello I've been on C++ for a day :O and I've started somthing for some fun
a texted based game called TextScape! but I'm having some problems with the functions can somone please run through it for me?




#include <iostream>
#include <string>
using namespace std;

// Declaring Variables
int Command;

int Gender;
string GenderO;
int Race;
string RaceO;
int Prof;
string ProfO;

int PLH;
int PLD;
int PLA;
int MOH;
int MOA;
int MOD;

string HelpRace = " ";
string HelpSex = " ";
string HelpProf = " ";
int PlayerRace (void)
{
// Human = 1, Dwarf = 2, Elf = 3, Orc = 4
if (Race == 1)
{
PLH = 100;
PLA = 43;
PLD = 23;
string RaceO = "Human";
}
if (Race == 2)
{
PLH = 120;
PLA = 35;
PLD = 34;
string RaceO = "Dwarf";
}
if (Race == 3)
{
PLH = 80;
PLA = 52;
PLD = 11;
string RaceO = "Elf";
}
if (Race == 4)
{
PLH = 130;
PLA = 52;
PLD = 1;
}


}
int PlayerSex (void)
{
// Male = 1, Female = 0
if (Gender == 1)
{
PLH += 5;
PLA += 10;
PLD += 5;
string GenderO = "Male";
}
if (Gender == 0)
{
PLH += 10;
PLA += 5;
PLD += 10;
string GenderO = "Female";
}
}
int PlayerProf (void)
{
// Berserker = 1, Mage = 2, Archer = 3, Defender = 4
if(Prof == 1)
{
PLA += 20;
PLD -= 10;
string ProfO = "Berserker";
}
if(Prof == 2)
{
PLA += 9;
PLH -= 16;
string ProfO = "Mage";
}
if(Prof == 3)
{
PLA += 20;
PLD += 2;
PLH -= 20;
string ProfO = "Archer";
}
if(Prof == 4)
{
PLA -= 10;
PLD += 30;
PLH += 30;
string ProfO = "Defender";
}
}

// coding

int Attack (int PLH, int PLD, int PLA, int MOH, int MOD, int MOA)
{
int DMG;
int Boost;
int A;
int B;
if (MOH > PLH) Boost = (PLH - MOH);
else
{
A = MOH / PLH * 10^2;
B = A - A - A;
Boost = B;
}

DMG = PLA - MOA + Boost;
}
int main ()
{
cout << "Welcome to Textscape!\n\n";
cout << "Textscape is still in Develoupment stage\nPlease send all bug to joshhua123@hotmail.com";
cout << "\nWould you like to be Male or Female.\n Type HelpSex for information on genders.\n Male = 1, Female = 0\n";
cin >> Gender;
cout << "You've Selected " << GenderO << " What Race would you like?, type HelpRace for information on Races.\n Human = 1, Dwarf = 2, Elf = 3, Orc = 4\n";
cin >> Race;
cout << "You've Selected " << RaceO << " What Profeshion will you follow?, Type HelpProf for information on Profrshions.\nBerserker = 1, Mage = 2, Archer = 3, Defender = 4\n";
cin >> Prof;
cout << "You are a " << GenderO << " " << RaceO << "that uses " << ProfO << " to destroy what ever's in it's path.";

// Charater process
PlayerRace ();
PlayerSex ();
PlayerProf ();
// end charater proccess continue with code.

cout << "Time for your first choice. Do you wan't to Attack, Check stats or Visit the store?\n";
cout << "Attack : Fight a random moster in a Kill or be killed situation.\n";
cout << "Shop : Visit a Show to upgrade or heal.\n";
cout << "States : Check current Chariter status.\n";
cin >> Command;
}
Am starter either, but i think in C++ function with type int,float e.t.c should return value with
return 
statement if there is no value to return you should write for example..
1
2
3
void playsex() {
//code goes here
}


Expert will tell you more.....
---Said Hemed
I shall take a look as soon as you indent propely... The way you have the code now is unreadable ;)
Mazd is right. make your functions void. main should be int and return 0.
Another problem is with your strings. For example, string RaceO = "Human"; is wrong. It declares a new local variable RaceO, while there is a global one (the one you really need). Change it (and other similar lines) to RaceO = "Human";
LOOK AT MY SAMPLE
1
2
3
4
5
6
7
8
9
10
11
12
13
//MY SAMPLE 
#include<iostream>
using namespace std;
int myfunc(int x){
	int y;
	y=x+2;
	return y;
};
int main(){
cout<<myfunc(2)<<endl;
system("PAUSE");
return 0;
}



OR
1
2
3
4
5
6
7
8
9
10
11
12
//MY SAMPLE 2
#include<iostream>
#include<string>
using namespace std;
void myfunc(){
	cout<<"hello"<<endl;
};
int main(){
myfunc();
system("PAUSE");
return 0;
}
Also look into function prototypes, and try to avoid using ANY global variables
Topic archived. No new replies allowed.