回复 11# 的帖子
是的。
在<stdlib.h>里面,sleep函数声明前面有这样一句注释:
/*
* NOTE: Officially the three following functions are obsolete. The Win32 API
* functions SetErrorMode, Beep and Sleep are their replacements.
*/
这里它说的三个函数就是:
_CRTIMP void __cdecl _beep (unsigned int, unsigned int);
_CRTIMP void __cdecl _seterrormode (int);
_CRTIMP void __cdecl _sleep (unsigned long);
这三个函数已经“过时”,他们被Win32 API相应的函数代替。既然代替,函数参数、返回值应该是一样的。我们来看一下MSDN里面关于Sleep的说明:
VOID Sleep(
DWORD dwMilliseconds // sleep time
);
dwMilliseconds
[in] Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay.
再看DWORD
DWORD : A 32-bit unsigned integer or the address of a segment and its associated offset
换句话说,DWORD在这里就是unsigned long
TC下面的函数没有任何参考意义。