hi
I'm trying to do something and looking around i've written this code:
Code:
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void){
int i,j=0,max=100000;
double usr_time, sys_time;
clock_t tcstart, tcend;
struct tms end,start;
if ((tcstart=times(&start))==-1){
printf("Error to get start time\n");
return 1;
}
for(i=0;i<max;i++){
j++;
}
if ((tcend=times(&end))==-1){
printf("Error to get final time\n");
return 1;
}
usr_time=end.tms_utime-start.tms_utime;
sys_time=end.tms_stime-start.tms_stime;
printf("%lf",usr_time);
printf("%lf",sys_time);
printf("\n");
return 0;
}
but when i try to compile i get:
error: storage size of ‘end’ isn’t known
error: storage size of ‘start’ isn’t known
I've included the time.h. anyone can help?
thanks