freakinjonathan
August 12th, 2009, 01:57 AM
Hey I found this code on the internet and it does exactly what i need it to do except for the fact that it returns a whole number. It won't return like You took 1.5 second to spell your name. It would just say 1 sec. I don't know what "%.2lf" is. I know it is the variable but i have never seen it like that before. Thanks.
/* difftime example */
#include <stdio.h>
#include <time.h>
int main ()
{
time_t start,end;
char szInput [256];
double dif;
time (&start);
printf ("Please, enter your name: ");
gets (szInput);
time (&end);
dif = difftime (end,start);
printf ("Hi %s.\n", szInput);
printf ("It took you %.2lf seconds to type your name.\n", dif );
return 0;
}
/* difftime example */
#include <stdio.h>
#include <time.h>
int main ()
{
time_t start,end;
char szInput [256];
double dif;
time (&start);
printf ("Please, enter your name: ");
gets (szInput);
time (&end);
dif = difftime (end,start);
printf ("Hi %s.\n", szInput);
printf ("It took you %.2lf seconds to type your name.\n", dif );
return 0;
}