I am trying to make a program that generates a random number and asks the user to input the random number generated by the computer. Anyone know how to do this?
This is my program:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int one;
time_t seconds;
time (&seconds) ;
srand((unsigned int) seconds);
cout<< rand() << endl;
cout<<"Enter this number: ";
cin>> one;
if (one == seconds) {
cout<<"\nSparta\n";
}
P.S.
This is part of a larger project and I couldn't figure this out. Any suggestions would be appreciated.
P.P.S.
I think the problem has something to do with the way I am generating a random number... Just a thought