This blog is under construction

Saturday, 5 May 2012

asctime example in C

Header file:
    time.h

Synopsis:
     char *asctime(const struct tm *tp);

Description:
     It converts the time in the structure *tp to a string format.


asctime function C example:


  #include<stdio.h>
  #include<time.h>
  int main() {
        struct tm *tp;
        time_t t;
        char *str;
        t = time(NULL);
        tp = localtime(&t);
        str = asctime(tp);
        printf("Output:%s\n", str);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/time$ ./a.out
  Output:Sat May  5 22:45:09 2012



No comments:

Post a Comment