Thread: System Date/Time

  1. #1
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644

    System Date/Time

    Ok, I tried doing the following:

    Code:
    	SYSTEMTIME sys;
    	CString datetime;
    
    	datetime.Empty();
    	datetime.Format("%i/%i/%i", sys.wMonth, sys.wDay, sys.wYear);
    
    	GetSystemTime(&sys);
    	AfxMessageBox(datetime);
    to display the current time/date at the time the action occurs. But what I get is something like: "5248/5248/5248" w/o the quotes. I looked up the SYSTEMTIME structure and the GetSystemTime(...) function, but I don't understand what I am actually doing wrong.

    So my question is, does anyone have any idea as to why it isn't showing the current date?

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    You are writing unintialised values to your string, then calling the routine that initialises them, do it the other way round.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Quote Originally Posted by adrianxw
    You are writing unintialised values to your string, then calling the routine that initialises them, do it the other way round.
    Thank you a lot! That fixed it greatly. I hate making those mistakes....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  2. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  3. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Problem Reporting System. Need Advide!
    By brunomiranda in forum Tech Board
    Replies: 9
    Last Post: 09-25-2003, 09:21 PM