unixdate.c
来自「Tornado train workshop的配套实验教材」· C语言 代码 · 共 31 行
C
31 行
/* unixDate.c - print the time & date */
#include <time.h>
#include <sys/types.h>
int main (void)
{
time_t tloc;
char *pStr;
/* Get the system time in seconds since the EPOCH */
if ((tloc = time ((time_t *)0)) == (time_t)0)
{
printf ("time() failed\n");
exit (1);
}
/* Convert the system time to an ASCII string */
if ((pStr = ctime (&tloc)) == NULL)
{
printf ("ctime failed\n");
exit (1);
}
printf ("%s\n",pStr);
return (0);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?