linker issues

I'm getting this error:
1>pokemon 2.obj : error LNK2028: unresolved token (0A00034D) "void __cdecl stats(void)" (?stats@@$$FYAXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>pokemon 2.obj : error LNK2019: unresolved external symbol "void __cdecl stats(void)" (?stats@@$$FYAXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

Anyone have any ideas of what could be the issue?

#include "stdafx.h"
#include "iostream"
#include "ctime"
#include "cstdlib"

using namespace std;

void blast ();
void kick ();
void punch ();
void sandstorm ();
void stats();
void enemyattack ();
int attack;
int phealth=50;
int enemyhealth=50;

int main()
{
cout <<"welcome to the fight simulator!" <<endl;

while (phealth>>0 && enemyhealth>>0);
{
stats();


if (attack==1)
{
blast();
}

else if (attack==2)
{
kick();
}

else if (attack==3)
{
punch();
}

else if (attack==4)
{
sandstorm();
}

enemyattack();

}


return 0;
}
void showstats()
{
cout <<"your health is"<< phealth << endl;
cout <<"your enemy's health is" << enemyhealth << endl;
cout <<"" << endl;
cout <<"pick an attack to attack!" <<endl;
cout <<"1-fire blast" <<endl;
cout <<"2-wicked kick" <<endl;
cout <<"3-whirlwind punch" <<endl;
cout <<"4-blinding sandstorm" <<endl;
cin >> attack;
}

void blast()
{
enemyhealth-=5;
}

void kick()
{
enemyhealth -=7;
}

void punch()
{
enemyhealth -=4;
}

void sandstorm()
{
enemyhealth-=5;
}

void enemyattack()
{
srand(static_cast<unsigned int>(time(0)));

int eattack =rand();

int efinal = (eattack % 4) + 1;

if (efinal==1)
{
phealth-=5;
cout <<"Enemy uses fire blast! You feel your skin crackle and burn!"<<endl;
}

if (efinal==2)
{
phealth-=7;
cout <<"Enemy uses spinning kick! Your chest erupts with pain as your sternum shatters!"<<endl;
}

if (efinal==3)
{
phealth-=4;
cout <<"Enemy uses whirlwind punch! The world dims as your brain begins to swell!"<<endl;
}

if (efinal==4)
{
phealth-=5;
cout <<"Enemy uses sandstorm! Your insides burn as your lungs drown in sand!"<<endl;
}
}
The error message is a bit hard to read but it does in fact identify the problem.
It states that in function main() you have a call to an unidentified function called stats().

The reason appears to be that the body of the function was defined with a different name void showstats()
This line is an error:
while (phealth>>0 && enemyhealth>>0);

A single > is the "greater than" sign, a double >> is the bitwise shift right operator.

I'd recommend you take a few minutes to review the operators:
http://www.cplusplus.com/doc/tutorial/operators/


In addition, the while statement above should not end in a semicolon.
Last edited on
It's alive, thanks for the help.
Topic archived. No new replies allowed.