Problem with initializing tm * variable.

This is a discussion on Problem with initializing tm * variable. within the C Programming forums, part of the General Programming Boards category; OK, this is purely to get rid of a compiler error "warning C4700: uninitialized local variable 'timeinfo' used". It's a ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    46

    Problem with initializing tm * variable.

    OK, this is purely to get rid of a compiler error "warning C4700: uninitialized local variable 'timeinfo' used".

    It's a trivial warning because timeinfo is used to store a value passed to it by localtime_s so its uninitialized state is irrelevant. However I'd like to get rid of it, and I think I'm just missing something very obvious indeed.

    Code:
    struct tm * timeinfo;
    
    #if defined(_MSC_VER) && (_MSC_VER >= 1400)
    	localtime_s(timeinfo, death_time);
    #else
    	timeinfo = localtime(death_time);
    #endif
    	strftime(entry->day, sizeof(entry->day), "@%Y%m%d", timeinfo);
    	my_strcpy(entry->day, "TODAY", sizeof(entry->day));
    How do I pass an arbitrary value to timeinfo to shut the compiler up?

    Obviously if there are other problems with my code I'd like to know. ;-).

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    20
    "warning C4700: uninitialized local variable 'timeinfo' used"

    change to this.
    Code:
    struct tm * timeinfo=NULL;

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    46
    Quote Originally Posted by xmariux View Post
    "warning C4700: uninitialized local variable 'timeinfo' used"

    change to this.
    Code:
    struct tm * timeinfo=NULL;
    Brilliant, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  2. Problem getting the input from a temp variable into the Array
    By hello_moto in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2006, 12:50 AM
  3. problem with the const variable
    By ssharish in forum C Programming
    Replies: 2
    Last Post: 01-28-2005, 08:53 AM
  4. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 12:25 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21