Results 1 to 4 of 4

Thread: getting the time

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question getting the time

    I don't understand why this won't work.

    Code:
    SYSTEMTIME stime;
    GetLocalTime(stime);
    
    
    --------------------Configuration: Dialog - Win32 Debug--------------------
    Compiling...
    Dialog.cpp
    C:\C++\Dialog\Dialog.cpp(15) : error C2501: 'GetLocalTime' : missing storage-class or type specifiers
    C:\C++\Dialog\Dialog.cpp(15) : error C2373: 'GetLocalTime' : redefinition; different type modifiers
            c:\program files\microsoft visual studio\vc98\include\winbase.h(2844) : see declaration of 'GetLocalTime'
    C:\C++\Dialog\Dialog.cpp(15) : error C2440: 'initializing' : cannot convert from 'struct _SYSTEMTIME' to 'int'
            No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    Error executing cl.exe.
    
    Dialog.exe - 3 error(s), 0 warning(s)

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I don't know the rest of your code but:

    1. Include the windows.h file
    2. GetLocalTime requires the address of the SYSTEMTIME structure
    so use
    Code:
    SYSTEMTIME stime;
    GetLocalTime(&stime);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    OK, It's fixed.
    How can I get stime.wHour & stime.wMinute & stime.wSecond
    into a string to print to a text box or message box?
    Last edited by wey97; Jun 12th, 2001 at 09:26 AM.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use sprintf (actually snprintf is better if you have it).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width