阅读:1614回复:6
ctime 函数在vc6中编译通不过???请指教
我是在看一本关于vc的书时看到的例子,他用的不是vc6,好想是低版本的
|
|
沙发#
发布于:2004-10-10 10:24
应该是缺少某个头文件造成的吧
|
|
板凳#
发布于:2004-10-10 10:44
好象得加一个"time.h"的头文件,记不太清啦,好象就是这个
|
|
地板#
发布于: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( <ime ); printf( "The time is %s\n", ctime( <ime ) ); } Output The time is Fri Apr 29 12:25:12 1994 Time Management Routines |
|
地下室#
发布于:2004-10-11 15:36
可在线查msdn看看
|
|
5楼#
发布于:2004-10-11 16:39
和我一样弱弱
|
|
|
6楼#
发布于:2004-10-15 15:41
Try Class CTime,
It's better. |
|
|