unixtimeserver.c

来自「嵌入式VxWorks开发的各种实验源代码以及相关教程」· C语言 代码 · 共 33 行

C
33
字号
/* unixTimeServer.c - example RPC server code */

#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include "time.h"

#define NULL					0

char ** print_time_1 (void)
	{
	time_t tloc;
	static char * pStr;

	/* Get system time in seconds since the EPOCH */

	if ((tloc = time ((time_t *)0)) == (time_t)(-1))
		{
		printf ("time() failed\n");
		return (NULL);
		}

	/* Convert the system time to an ASCII string */

	if ((pStr = ctime (&tloc)) == NULL)
		{
		printf ("ctime failed\n");
		return (NULL);
		}

	return (&pStr);
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?