Dave's Brain

Browse - Programming Tips - How do I deal with time_t in an _snprintf() ?

Date: 2010mar23
Language: C/C++
Platform: Windows
Keywords: 64, bit, print, printf, snprintf, fprintf

Q.  How do I deal with time_t in an _snprintf() ?

A.  As of Visual Studio 2005, it is signed 64 bits so do:

char buf[100]; time_t now; now = time(NULL); _snprintf(buf, sizeof(buf), "time=%I64d seconds", now);

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.