time_t is defined in time.h as :
typedef unsigned int time_t;
In my opinion it should be defined as :
typedef long time_t;
Am I right ?
printf("Time: %lu\n",(long)t);
Better make that:
printf("Time: %lu\n",(unsigned long)t);
Or, if available, make use of the extensions to integer types and printf formats in Standard C99.
Slip of the finger. The typecast is correct, but it should be "%ld", and not "%lu". The time_t datatype is signed just because it should be possible to store a negative difference in it.
This is the big reason why the data type isn't just changed from long to unsigned long - a lot of programs would break then. In early 2038, we will see if your microcontrollers have suddenly become 64-bit or if a lot of hardware appliances will suddenly break :)
C99 isn't always available :(