Hey guys! Just relearning c++ and i'm running into this error. I remember addressing it in high school but, that was years ago. Thank you in advanced!
The error is coming up in line 13(srand() issue I think) of the following code:
using namespace std;
int main(int argc, char *argv)
int i =1;
int magic; //computer-generated number
int guess; //user input
magic = srand(time(0)) ; //get a random nuber (within the specified type)
cout << "Guess the magic number: ";
cin >> guess;
if(guess == magic)
cout << "Correct! The magic number was " << magic << endl;
cout << "You needed " << i << " tries to guess the number\n";
cout << "Incorrect..\n";
if(guess > magic) cout << "Your guess was too high\n";
else cout << "Your guess was too low\n"; i++;
} while (guess != magic);
I'm sure it's something really simple that I'm overlooking. I've looked at several solutions but, it seems to apply to that specific code. Please help!
Last edited on
Thank you so much! I knew it was something simple like that. srand turns the engien on, and rand actually drives (to use an analogy of sorts).
So then, what are some other places besides time that srand can seed. could I use an algebraic equation based on user input (variables x, y, etc)? something like srand(x +y)?