CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: time_t to unsigned int possible loss

  1. #1
    Join Date
    Oct 2009
    Posts
    29

    time_t to unsigned int possible loss

    Ok so sometime when I use srand I get the possible loss of data conversion "warning" and sometimes not. I think it has to do with placement inside the code but not sure. Can someone explain why I ocasionally get this warning and how to avoid it.

  2. #2
    Join Date
    Jun 2007
    Location
    MA-USA
    Posts
    247

    Re: time_t to unsigned int possible loss

    You mean like...
    Code:
    srand(time(NULL));
    But you should cast like...
    Code:
    srand((unsigned)time(NULL));
    I bet your compiler would complain everytime if you build all.

  3. #3
    Join Date
    Oct 2009
    Posts
    29

    Re: time_t to unsigned int possible loss

    Quote Originally Posted by bitshifter420 View Post
    You mean like...
    Code:
    srand(time(NULL));
    But you should cast like...
    Code:
    srand((unsigned)time(NULL));
    I bet your compiler would complain everytime if you build all.
    Yea what I am doing is srand(time(0)) and I get that warning message everytime. functions the way i want but still get the message

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)