joomla.2038bug.com

  • Increase font size
  • Default font size
  • Decrease font size
Home Articles General Year 2038 Bug Example

Year 2038 Bug Example

E-mail Print PDF

An example C program 

The following C program demonstrates this effect. It is strict ANSI C so it should compile on all systems that support an ANSI C compiler.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>

int main (int argc, char **argv)
{
 time_t t;
 t = (time_t) 1000000000;
 printf ("%d, %s", (int) t, asctime (gmtime (&t)));
 t = (time_t) (0x7FFFFFFF);
 printf ("%d, %s", (int) t, asctime (gmtime (&t)));
 t++;
 printf ("%d, %s", (int) t, asctime (gmtime (&t)));
 return 0;
}



The program produces the output:

1000000000, Sun Sep  9 01:46:40 2001
2147483647, Tue Jan 19 03:14:07 2038
-2147483648, Fri Dec 13 20:45:52 1901

Last Updated on Saturday, 24 April 2010 21:38  

Users Online

None

Polls

Year 2038 Bug