|
发表于 2007-3-22 11:22:28
|
显示全部楼层
Post by fxb248
代码如下,请各位看看:
#include <time.h>
#include <stdio.h>
int main()
{
struct tm *tm_ptr;
time_t the_time;
(void) time(&the_time);
tm_ptr = gmtime(&the_time);
printf("Raw time is %ld\n",the_time);
printf("gmtime gives:\n");
printf("date:%02d/%02d/%02d\n",tm_ptr->tm_year,tm_ptr->tm_mon+1,tm_ptr->tm_mday);
printf("time:%02d:%02d:%02d\n",tm_ptr->tm_hour,tm_ptr->tm_min,tm->tm_sec);
exit(0);
}
这是Beginning Linux Programming上的例程代码,应该没有错误,除非楼主打字大错喽!! |
|