Thread: time.h and time_t

  1. #1
    Unregistered
    Guest

    time.h and time_t

    i seem to having a lot! of trouble getting the system date into this format yyyymmdd and i have been trying out the time_t struct thing but i cant seem to get it to work... when i try to display things using it crashes anyone have any examples

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main ( ) {
        char    buff[100];
        time_t  now;
        now = time(NULL);
        strftime( buff, sizeof(buff), "%Y%m%d", localtime(&now) );
        printf( "Now=%s\n", buff );
        return 0; 
    }

  3. #3
    Unregistered
    Guest
    salem i bow down to you lol i cant believe my problem was this simple! i forgot to time(NULL);

Popular pages Recent additions subscribe to a feed