Hello I am trying to learn how to add time limit expiration using this code but the problem is that is gives me an error saying " error C2065: 'timer' : undeclared identifier" when "timer" is suppose to be part of the time.h library (the pointer i I think). I don't know what's going on with it and I need to hand it in soon. Anybody knows??
printf("Guess the 2 words as many trials within 3minutes");
int minutes = 3 ;
while ( timer < minutes * 60 ) // convert minutes to seconds
{
printf("");
scanf("%s", &ans);
gethchar() ; // for the extra new line because of scanf()
OK. But my major problem is that the variable timer still as an undeclared variable showing the same message 'timer' : undeclared identifier"
when is supposed to be part of time.h. Pretty much I am trying to manage time and have a time expiration using a loop. I don't know if i am using the right library or doing the right thing.
Well I guess that assumption threw me off I should've noticed that but well every mistake is part of the learning process. Thanks for everything. THIS CODE CERTAINLY WORKS.
int score=0;
char ans[10];
double timer=NULL; //TIMER IS INITIALLY 0.
time(&start); //start timer
printf("Guess the 2 words as many trials within 1 minutes");
int minutes = 1 ;
while ( timer < minutes * 60 ) // convert minutes to second
{
printf("");
scanf_s("%s", &ans);
getchar() ; // for the extra new line because of scanf()