INFO: Consecutive Calls to ctime() Overwrite Previous Values (33795)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
This article was previously published under Q33795 NOTE: Microsoft Visual C++ NET (2002) supported both the managed code
model that is provided by the .NET Framework and the unmanaged native Windows
code model. The information in this article applies to unmanaged Visual C++
code only. SUMMARY Subsequent calls to the ctime() function overwrite the
results of a previous call. The code example below demonstrates this behavior
by printing the same time for the start time and finish time in its first
printf() call. However, the start and finish times should be different. To
correct this situation, do not call ctime twice in one call to printf. Then the
finish time is later than the start time, as expected.
This is
expected behavior. The ctime() function uses one static buffer to store its
results. Therefore, when the second ctime() call is made in the printf
function, ctime() overwrites the value returned by the first ctime() call.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbinfo KB33795 |
---|
|