I'm writing a program in C-language which its a simulation program for one barbershop one chair model under Ubuntu 13.04 environment .
I have a timer () function which gives me this error :
storage size of ‘t’ isn’t known>>
here is the function and the instruction which call it :
#include<time.h>
#include<math.h>
#include<stdlib.h>
the function :
long timer()
{
//get current system time
struct time t;
gettime(&t);
//return number of hundred of second
return(((long)3600*t.ti_hour+60*t.ti_min+t.ti_sec)*100+t.ti_hund);
}
the instruction which call this function :
srand((unsigned) timer());
may questions are :
1- what that's error main ?
2-how can I fix this error ?
If you are on ubuntu, you can just do:
You don't need your own
timer()
function. If you need more fine resolution than 1 second, look intogettimeofday
.You seem to be trying to run MS-DOS / Turbo-C code on Linux?
There's no
struct time
andgettime()
function in the Unix C library, you're probably looking forstruct tm
andlocaltime()
instead, see e.g.:http://www.tutorialspoint.com/c_standard_library/c_function_localtime.htm