Thread: Need VS2008 Verification

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

    Need VS2008 Verification

    OK, I've been banging my head over what appears to be some weird behavior in the CRT under VS2008 (debug mode). Here's the code:
    Code:
    const time_t timeStamp = 1223939307;
    char qs[256] = { 0 };
    int actualLen = sprintf_s(qs, sizeof(qs), "%lu----%s---", timeStamp, "rukiddingme?");
    Yields (in the debugger):
    Code:
    qs = 0x0012e998 "1223939307----(null)---"
    It seems if I put that timestamp in an _snprintf, sprintf, or sprintf_s, the string which follows ends up (null) in the resulting string.

    Can anyone verify this? Have I lost the ability to use sprintf over the weekend? It really was totally not wild, although I was dealing with Vista at one point...

    Visual Studio 2008 on XP Professional
    Compilation command line:
    Code:
    /Od /I "..\openssl\include" /I "..\ShareFiles\C" 
    /I "C:\Program Files\Microsoft SDKs\Windows\v6.0A\\Include" 
    /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "HELPER_EXPORTS" 
    /D "_CRT_SECURE_NO_WARNINGS" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" 
    /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" 
    /W3 /c /ZI /TP .\utils.cpp
    Link command line:
    Code:
    /OUT:"..\BuildFiles/Helper.dll" /INCREMENTAL /DLL 
    /MANIFEST /MANIFESTFILE:"Debug\IHelper.dll.intermediate.manifest"
    /MANIFESTUAC:"level='asInvoker' uiAccess='false'" 
    /DEF:"Helper.def" /DEBUG /PDB:"..\BuildFiles/Helper.pdb" 
    /SUBSYSTEM:WINDOWS /DYNAMICBASE:NO 
    /IMPLIB:"..\BuildFiles/Helper.lib" 
    /MACHINE:X86 "C:\Program Files\Microsoft SDKs\Windows\v6.0A\\Lib\winhttp.lib" 
    
    ..\openssl\lib\libeay32.lib ..\openssl\lib\ssleay32.lib 
    kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
    advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
    Thanks!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Is sizeof(time_t)==sizeof(long)?

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Nope, it's actually unsigned int (damn my Linux-based expectations), but sadly, changing the format specifier to %u did not change the behavior.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    sizeof(%lu) == 4 (sizeof(%u) is also 4)
    sizeof(time_t) == 8
    Can you spot the error?
    Last edited by Elysia; 10-13-2008 at 01:07 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Dammit, what the hell was I thinking...in my haste I read the sizeof output incorrectly in the debugger...

    And hence, how I achieved my hat of Ass.

    Thanks, Elysia!

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    "You made me look quite the fool, thanks Elysia!!!!"

    Man I hope that makes it to her sig.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I don't want to add something insulting to the signature.
    Without proper permission and desire from the original poster. And of course, it could be removed at any time. But I don't think it's necessary.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Configuring VS2008 C++ to C
    By Akkernight in forum C Programming
    Replies: 8
    Last Post: 02-28-2009, 04:17 AM
  2. MASM In VS2008
    By valaris in forum Tech Board
    Replies: 1
    Last Post: 01-13-2009, 09:11 PM
  3. Does VS2008 have anything like Pythons IDLE?
    By atomsmasher442 in forum C# Programming
    Replies: 1
    Last Post: 07-26-2008, 04:37 AM
  4. Password verification
    By WannaB_Geek in forum C++ Programming
    Replies: 1
    Last Post: 08-24-2004, 12:58 PM
  5. password verification on startup
    By codefx in forum C++ Programming
    Replies: 12
    Last Post: 04-17-2003, 05:42 AM