Results 1 to 5 of 5

Thread: Use of mktime() : C

  1. #1
    Join Date
    Jan 2010
    Posts
    29

    Use of mktime() : C

    Hello, I am the student of the MCA second year. I had learn the C language in the BscIT. I know about some of the header files of the C language. So, I want to know about the mktime() function. I also want to know about the what is actual use of the mktime() function, How mktime() function works, and How can I implement the mktime() function in the C language. If anyone has the any idea about the mktime() function, so Please reply me.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Use of mktime() : C

    Hi, The information of the local time can be converted in the structure that can be pointed to by pointer of the time into a calendar time i.e. Coordinated Universal Time, with the similar kind of encoding that is being used by the function time(), by the mktime() function. The following can be the syntax of the mktime(0 function :
    #include <time.h>
    tim_t mktime( struct t *tmpr );

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Use of mktime() : Program

    Program :
    Code:
    #include <stdio.h>                                                              
    #include <time.h>                                                               
    char *wdy[] = { "Sunday", "Monday","Tuesday","Wednesday",                    
                     "Thursday", "Friday", "Saturday" };                            
    int main(void)                                                                  
    {                                                                               
     tim_t t2, t4;                                                                
      struct tn *t3;                                                                
      t2 = time(NULL);                                                              
      t3 = localtime(&t2);                                                          
      t3 -> t_mdy += 40;                                                          
      t3 -> t_hr += 16;                                                          
      t4 = mktime(t3);                                                              
    printf("40 days and 16 hours from now, it will be a %s \n",                   
              wday[t2 -> tm_wday]);                                                 
    }
    The Output of the program :
    Code:
    40 days and 16 hours from now, it will be a Sunday
    Last edited by Praetor; 02-02-2010 at 08:40 PM.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    The mktime() : C

    The tzset() function can be called, when you called the mktime() function. there can be one more example on the mktime() function :
    Code:
    #include <stdio.h>
    #include <time.h>
    static const char *wk_dy[] = {
        "Sunday", "Monday", "Tuesday", "Wednesday",
        "Thursday", "Friday", "Saturday"
    };
    void main()
      {
        struct t nw_yr;
        nw_yr.t_yr  = 2001 - 1900;
        nw_yr.t_mn   = 0;
        nw_yr.t_mdy  = 1;
        nw_yr.t_hr  = 0;
        nw_yr.t_mn   = 0;
        nw_yr.t_sc   = 0;
        nw_yr.t_isdst = 0;
        mktime( &nw_yr );
        printf( "The next century begins on a %s\n",
             wk_dy[ nw_yr.t_wdy ] );
      }
    OUTPUT :
    The next century begins on a Monday

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Use of mktime()

    Hi, According to my knowledge about the mktime() function, The incomplete time form can be converted into the completely defined format that can be pointed to by the time pointer with the value that can be normalized and converts that time into the calender time. Thus, that converted time can contain the similar encoding as that value can be returned by the time().

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,310,278.55301 seconds with 15 queries