I use timers a good deal, but not this kind. This works, so give it a try.
Code:
#include <stdio.h>
#include <time.h>
int main(void) {
int i;
char a[7][128];
time_t start, stop;
FILE *fp=fopen("Edelweiss.txt", "r");
if(!fp) {printf("\nError: unable to open the file.\n"); return 1;}
start = time(NULL);
i=0;
while((fgets(a[i],sizeof(a[i]), fp)) != NULL) {
fputs(a[i++],stdout);
getchar();
}
fclose(fp);
stop = time(NULL);
if(stop-start > 10) {
printf("\nYour 10 seconds are up! Ending program in 2 seconds!\n");
_sleep(2);
}else {
printf("\nYou were fast! The program will end when you hit enter\n");
getchar();
}
return 0;
}
/*
In a file named "Edelweiss.txt, put this into the programs directory before you run it:
"Edelweiss, edelweiss, every morning you greet me.
Small and white, clean and bright, you look happy to meet me.
Blossom of snow may you bloom and grow, bloom and grow forever.
Edelweiss, edelweiss, bless my homeland forever.
Small and white, clean and bright, you look happy to meet me
Blossom of snow, may you bloom and grow, bloom and grow forever.
Edelweiss, edelweiss, bless my homeland forever."
*/