problems running simple prog
Hi all, I am very new to c++, in fact I have only read a few beginners tutorials in the last 2 days, however... I do script for a game NWN which involves some c++ based programming although there are alot of similarities theres also alot of differences, Anyway I just thought I would experiment by creating a simple number guesssing game using the Dev-c++ compiler, the problem is that the program will not even run, could this be a bug or is it in the program I created?
Code:
////////////////////////////////////////////////////////////////////////////////
//:: Number guessing game
//:: First ever c++ program written by Scott Clarke
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int NumberCheck(int nNumIGuess, int nYourNum, int nNumOfGuesses);
int main()
{
int nNumIGuess = rand() % (1 - 10 + 1);
int nYourNum;
int nNumOfGuesses;
cout<<"You have three guesses to work out which number I am thinking of ";
"between 1 - 10. \nEach time you guess I will tell you if the number "
"I am thinking of is higher or lower. ";
while (nNumOfGuesses < 3)
{
cout<<"\nGuess what number I am thinking of? ";
cin.ignore();
cin>>nYourNum;
cin.get();
NumberCheck(nNumIGuess, nYourNum, nNumOfGuesses);
}
}
int NumberCheck(int nNumIGuess, int nYourNum, int nNumOfGuesses)
{
nNumOfGuesses++;
if (nYourNum < nNumIGuess)
{
cout<<"\nIncorrect, the number I am thinking of is higher";
}
else if (nYourNum > nNumIGuess)
{
cout<<"\nIncorrect, the number I am thinking of is lower";
}
else
{
cout<<"\nCorrect!!!! You win";
}
return nNumOfGuesses;
}
Thanks for your time.
Scott