View Single Post
Old 10-13-2004, 04:00 AM   #1 (permalink)
if13121
Registered User
 
if13121's Avatar
 
Join Date: Oct 2004
Location: Bandung,Indonesia
Posts: 16
if13121 is on a distinguished road
problems get local time using sys/time.h

Dear All, Please help me.
i can't run this program under linux.
I got :
calljam.c:19: warning: assignment makes pointer from integer without a cast
calljam.c:20: dereferencing pointer to incomplete type
...
...
It works under Windows but when i print L.DD, L.MM, L.YYYY it return number such 121367232732
the program:
Code:
/* File : calljam.c */ 
#include <sys/time.h> 
#include <stdio.h> 
typedef struct
{
  int DD;
  int MM;
  int YYYY;
}date;

int main () 
{ 
  date L;	
  time_t now; 
  struct tm *T; 
 
  now = time(NULL); 
  T = localtime (&now); 
  printf ("Jam = %d:%d:%d\n ", 
          T->tm_hour, T->tm_min, T->tm_sec); 
  printf ("Date = %d-%d-%d\n ",
          T->tm_mday, T->tm_mon + 1, T->tm_year+1900); 
  printf ("local time %s\n", asctime (T)); 
  L.DD   = T->tm_mday;
  L.MM   = T->tm_mon + 1;
  L.YYYY = T->tm_year + 1900;
  printf ("Date = %d-%d-%d\n ", L.DD, L.MM, L.YYYY); 
  return 0; 
}

Last edited by redhead; 10-13-2004 at 07:41 AM.
if13121 is offline   Reply With Quote