I don't entirely understand what you're trying to do, as you don't call the
timer function, and it doesn't seem to do anything anyway, except count from 60 to zero and then exit.
Also, you have the return type of
timer defined as int, but you don't return anything.
You also test to see if the variable
I is 0 (line 15), yet it must be zero otherwise you wouldn't have gotten past the while loop.
As mentioned above, you have a little error in your code, as you presumably want to add on 60 to
I once you know it's zero, but then you'll exit the function anyway, so it really makes no difference whether you add on 60 or not, and next time into the function you're going to set
I to 60 again.
In essence, it would seem you could write your
timer function as below, and it would have the same effect (i.e. it'll take just a fraction of a second to execute and really does nothing):
1 2 3 4
|
void timer() {
int i = 60;
while (i > 0)--i;
}
|
The
main function, with the random number generation, might be better written as per Andy's comment, or such as below:
1 2 3 4 5
|
int main(){
srand (time(NULL));
int random = rand() % 10 + 1;
cout << random << endl;
}
|
Sorry if I'm misunderstanding what you're doing, but I'm sure you'll get all the help you need on here. Good luck.