Ok so I have been following a tutorial on youtube and trying to get my feet wet. I am having a problem in understanding the srand function.
It's your basic high and low guess game. The problem I am having is why it will not compile with the current srand function?
Any helpful responses/links to info would be of great help. I have looked all over google it seems and I can't find anything that covers this specifically. Thanks all.
Errors Seeing:
C++ project\New project\main.cpp|18|error: expected ';' before 'cin'|
C++ project\New project\main.cpp|18|warning: statement has no effect|
C++ project\New project\main.cpp|21|error: 'srand' was not declared in this scope|
C++ project\New project\main.cpp|29|error: expected ';' before 'cin'|
C++ project\New project\main.cpp|43|warning: statement has no effect|
Below is the code:
#include <iostream>
#include<ctime>
using namespace std;
int main ()
{
int iGumballs;
int iUserguess;
int iGuesses = 0;
while (true)
{
("CLS")
cin.clear();
iGuesses = 0;
srand (static_cast < unsigned int > (time(0)));
iGumballs = srand()%1000+1;
cout << "How many gumballs are in the gumball jar?" << endl;