Jan 26, 2011 at 4:23pm Jan 26, 2011 at 4:23pm UTC
Ok so my game is runing, but i get some errors when runing the exe\Debug.
And one Warning in the compiler.
1>------ Build started: Project: tut 16, Configuration: Debug Win32 ------
1>Compiling...
1>tut 16.cpp
1>d:\kjell\kodeing\c++\tut 16\tut 16\tut 16.cpp(16) : warning C4700: uninitialized local variable 'playerGuese' used
1>Linking...
1>Embedding manifest...
1>Build log was saved at "file://d:\KJELL\KODEING\C++\tut 16\tut 16\Debug\BuildLog.htm"
1>tut 16 - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
And here is the code:...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand((unsigned )time(0));
int thenumber = rand();1, 1000 +1;
int playerGuese;
int numOfGuses = 0;
while (playerGuese != thenumber){
cout << "How many stars can i see?" << endl;
cout << "Enter a guese: " ;
cin >> playerGuese;
if (playerGuese > thenumber){
cout << "To Hige!" << endl;
numOfGuses++;
}
if (playerGuese < thenumber){
cout << "To Low!" << endl;
numOfGuses++;
}
if (playerGuese == thenumber){
cout << "You are correct! \n You used " << numOfGuses << endl;
}
}
system("PAUSE" );
return 0;
}
I know i probeboly dont need all the #includes but not shure whats where :p.
Thanks to all that can help me shed some light on this.
Aprichiat it....
Edit:
This solved the problem.
int playerGuese = 0;
Last edited on Jan 26, 2011 at 4:26pm Jan 26, 2011 at 4:26pm UTC
Jan 26, 2011 at 4:33pm Jan 26, 2011 at 4:33pm UTC
Whats the 1, 1000 + 1; doing there on line 12?
Jan 26, 2011 at 6:10pm Jan 26, 2011 at 6:10pm UTC
wolfgang:
To be perfectly honest i googeld for random number code for C++.
And found this to work. It is supused to make the random number range from.
1 - 1000 But honestly i dont know how way.
The rest of the code i made\ writen my self.. :p
Im a noob ok :).