C++ Printing Time Only to a file!
How can I pr开发者_如何学Pythonint only the current time (not the date) to a file? I need it in this format...
13:55:36
I've tried a few different ideas but they all include the date too.
Try perusing this ctime reference
A combination of using time()
, localtime()
, strftime()
, and the struct tm
should get you there
Try strftime()
Use strftime! There is a code example on that page showing how to prepare for use of this function using time(), localtime()...
char timestring[12];
strftime(timestring,sizeof(timestring),"%T",timestruct);
puts(timestring);
精彩评论