通过使用引用来替代指针,会使 C++ 程序更容易阅读和维护。C++ 函数可以返回一个引用,方式与返回一个指针类似。 当函数返回一个引用时,则返回一个指向返回值的隐式指针。这样,...
描述 C 库函数 time_t time(time_t *seconds) 返回自纪元 Epoch(1970-01-01 00:00:00 UTC)起经过的时间,以秒为单位。如果 seconds 不为空,则返回值也存储在变量 seconds 中。 声明 下面是 time() 函数的...
描述 C 库函数 char *ctime(const time_t *timer) 返回一个表示当地时间的字符串,当地时间是基于参数 timer 。 返回的字符串格式如下: Www Mmm dd hh:mm:ss yyyy 其中, Www 表示星期几, Mmm 是以字母...
描述 C 库函数 struct tm *localtime(const time_t *timer) 使用 timer 的值来填充 tm 结构。 timer 的值被分解为 tm 结构,并用本地时区表示。 声明 下面是 localtime() 函数的声明。 struct tm *localtime(con...
描述 C 库函数 clock_t clock(void) 返回程序执行起(一般为程序的开头),处理器时钟所使用的时间。为了获取 CPU 所使用的秒数,您需要除以 CLOCKS_PER_SEC。 在 32 位系统中,CLOCKS_PER_SEC 等于...
描述 C 库函数 char *asctime(const struct tm *timeptr) 返回一个指向字符串的指针,它代表了结构 struct timeptr 的日期和时间。 声明 下面是 asctime() 函数的声明。 char *asctime(const struct tm *timeptr) 参...
描述 C 库函数 struct tm *gmtime(const time_t *timer) 使用 timer 的值来填充 tm 结构,并用协调世界时(UTC)也被称为格林尼治标准时间(GMT)表示。 声明 下面是 gmtime() 函数的声明。 struct tm *...
描述 C 库函数 time_t mktime(struct tm *timeptr) 把 timeptr 所指向的结构转换为自 1970 年 1 月 1 日以来持续时间的秒数,发生错误时返回-1。 声明 下面是 mktime() 函数的声明。 time_t mktime(struct t...
描述 C 库函数 double difftime(time_t time1, time_t time2) 返回 time1 和 time2 之间相差的秒数 (time1 - time2) 。这两个时间是在日历时间中指定的,表示了自纪元 Epoch(协调世界时 UTC:1970-01-01 00:00...
描述 C 库函数 size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) 根据 format 中定义的格式化规则,格式化结构 timeptr 表示的时间,并把它存储在 str 中。 声明 下面是...