显示时间

C语言打印时间方法(1)

#include <time.h>
#include <stdio.h>

int main()
{
  time_t rawtime;
  struct tm * timeinfo;
  char string[128];

  time(&rawtime);
  timeinfo = localtime(&rawtime);
  strftime(string, sizeof string, "%a %b %d, %I:%M %p", timeinfo);

  printf("time=%s\n", string);
}

 

posted on 2013-06-25 17:12  cfox  阅读(108)  评论(0)    收藏  举报

导航