TANGJKD
驱动牛犊
驱动牛犊
  • 注册日期2004-02-22
  • 最后登录2004-10-10
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1553回复:6

ctime 函数在vc6中编译通不过???请指教

楼主#
更多 发布于:2004-10-10 09:20
我是在看一本关于vc的书时看到的例子,他用的不是vc6,好想是低版本的
hhyjmd
驱动牛犊
驱动牛犊
  • 注册日期2004-06-11
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分104分
  • 威望11点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-10-10 10:24
应该是缺少某个头文件造成的吧
s_6666_s_qd
驱动巨牛
驱动巨牛
  • 注册日期2004-08-14
  • 最后登录2006-07-11
  • 粉丝0
  • 关注0
  • 积分199分
  • 威望22点
  • 贡献值0点
  • 好评度14点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-10-10 10:44
好象得加一个"time.h"的头文件,记不太清啦,好象就是这个
xx_focus
驱动中牛
驱动中牛
  • 注册日期2003-08-06
  • 最后登录2007-06-08
  • 粉丝0
  • 关注0
  • 积分96分
  • 威望10点
  • 贡献值0点
  • 好评度8点
  • 原创分0分
  • 专家分0分
地板#
发布于:2004-10-10 20:18
ctime, _wctime
Convert a time value to a string and adjust for local time zone settings.

char *ctime( const time_t *timer );

wchar_t *_wctime( const time_t *timer );

Routine Required Header Compatibility
ctime <time.h> ANSI, Win 95, Win NT
_wctime <time.h> or <wchar.h> Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version


Return Value

Each of these functions returns a pointer to the character string result. If time represents a date before midnight, January 1, 1970, UTC, the function returns NULL.

Parameter

timer

Pointer to stored time

Remarks

The ctime function converts a time value stored as a time_t structure into a character string. The timer value is usually obtained from a call to time, which returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC). The string result produced by ctime contains exactly 26 characters and has the form:

Wed Jan 02 02:03:55 1980\n\0

A 24-hour clock is used. All fields have a constant width. The newline character ('\n') and the null character ('\0') occupy the last two positions of the string.

The converted character string is also adjusted according to the local time zone settings. See the time, _ftime, and localtime functions for information on configuring the local time and the _tzset function for details about defining the time zone environment and global variables.

A call to ctime modifies the single statically allocated buffer used by the gmtime and localtime functions. Each call to one of these routines destroys the result of the previous call. ctime shares a static buffer with the asctime function. Thus, a call to ctime destroys the results of any previous call to asctime, localtime, or gmtime.

_wctime is a wide-character version of ctime; _wctime returns a pointer to a wide-character string. _wctime and ctime behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine  _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tctime ctime ctime _wctime


Example

/* CTIME.C: This program gets the current
 * time in time_t form, then uses ctime to
 * display the time in string form.
 */

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

void main( void )
{
   time_t ltime;

   time( &ltime );
   printf( "The time is %s\n", ctime( &ltime ) );
}


Output

The time is Fri Apr 29 12:25:12 1994


Time Management Routines
zsh_7769
驱动小牛
驱动小牛
  • 注册日期2004-04-15
  • 最后登录2005-12-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2004-10-11 15:36
可在线查msdn看看
SUNSHANGXIN
驱动老牛
驱动老牛
  • 注册日期2002-11-19
  • 最后登录2009-08-01
  • 粉丝0
  • 关注0
  • 积分21分
  • 威望19点
  • 贡献值0点
  • 好评度9点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2004-10-11 16:39
和我一样弱弱
[b]苍白的,不是文字,是人的思想 虚伪的,不是网络,是人的灵魂 伤心的,不是爱情,是人的心灵 难忘的,不是容貌,是人的思诀 黎明的曙光早已不见了夕日的辉煌 东方的日出早就失去了往日的灿烂 而我也尽脱了昨日的笑容去迎接明天的枯涩 [/b]
zmwk
驱动中牛
驱动中牛
  • 注册日期2001-05-15
  • 最后登录2009-04-05
  • 粉丝0
  • 关注0
  • 积分59分
  • 威望51点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2004-10-15 15:41
Try Class CTime,
It's better.
A strong man can save himself. A great man can save another.
游客

返回顶部