Hi guys. I have encountered a strange error which is probably neither synthax nor logical. It is related to improper usage of functions i suppose.
Here is the code:
//---------------------------------------------------------------------------
#include<iostream.h>
#include<conio>
#pragma hdrstop
int rollDice();
int krepsStat (void);
int process (int);
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{ constint arraySize = 1000;
cout << "Playing kreps 1000 times gives us the following statistic: \n";
int i, masskrep [arraySize],win=0,loss=0;
randomize();
for (i=0;i<arraySize;i++)
{masskrep[i] = krepsStat();
if (masskrep[i] == 1)
win++;
else
loss++;}
cout << "Amount of wins is " << win<<endl<<"Amount of losses is "<<loss<<endl;
getch();
return 0;
}
//---------------------------------------------------------------------------
int krepStat()
{
int gameStatus;
int sum;
sum = rollDice();
gameStatus = process(sum);
if (gameStatus == 1)
return 1;
elsereturn 0;
}
int rollDice()
{
int die1 = 1 + rand()%6;
int die2 = 1 + rand()%6;
int dice = die1 + die2;
return dice;
}
int process (int sum1)
{ int gameStatus1,myPoint;
switch (sum1){
case 7:
case 11:
gameStatus1 = 1;
break;
case 2:
case 3:
case 12:
gameStatus1 = 0;
break;
default:
gameStatus1 = 2;
myPoint = sum1;
break;
}
while (gameStatus1 == 2) {
sum1 = rollDice();
if (sum1 == myPoint)
gameStatus1 = 1;
if (sum1 == 7)
gameStatus1 = 0;}
return gameStatus1;
}
and this is the message of the mistake:
[Linker Error] Unresolved external 'krepsStat'referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\KREPS2\UNIT1.OBJ
If someone can explain me what is going on and what should i do to correct this code and how to escape these mistakes in future it would be really appreciated. Thank you very much in advance.