Printing System time and 30 minute alarm

This is a discussion on Printing System time and 30 minute alarm within the C Programming forums, part of the General Programming Boards category; well this is what i got and the code compiles but and gives me the current time and then gives ...

  1. #16
    Registered User
    Join Date
    Oct 2006
    Posts
    23

    new code new error

    well this is what i got and the code compiles but and gives me the current time and then gives me an error and boots out.

    Code:
    {
        time_t t1;                                 
        struct tm *tptr;
        clock_t ticks;                             
        char *s;
        struct tm *ntptr;
    
        if ( ( t1 = time(( time_t * ) 0 )) != ( time_t )-1 ) 
    	{
            s = ctime( &t1 );
            printf( "Current time is %s", s );
            tptr = localtime( &t1 );
            ntptr->tm_min = mktime(tptr->tm_min += 30);
            printf( "You have an appointment in 30 minutes at time %d:%d:%d.\n",              
                                           ntptr->tm_hour, 
                                           ntptr->tm_min,          
                                           ntptr->tm_sec );
          
           }
        else
            printf( "Error with the time() function\n" );
    
                                                              
        
        return 0;
    }

  2. #17
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    Erm, try reading the manual page?

    time_t
    mktime(struct tm *tm);

    Code:
    time_t now = time(NULL);
    struct tm tnow = localtime( &now );
    tnow.tm_min += 30;
    time_t later = mktime( &tnow );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 07:51 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  3. Time to seconds program
    By Sure in forum C Programming
    Replies: 1
    Last Post: 06-13-2005, 08:08 PM
  4. time of system
    By arian in forum C++ Programming
    Replies: 3
    Last Post: 12-10-2003, 11:51 AM
  5. Replies: 72
    Last Post: 11-25-2002, 04:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21