Questions tagged «time-t»

9
在C中获取当前时间
我想获取系统的当前时间。为此,我在C中使用以下代码: time_t now; struct tm *mytime = localtime(&now); if ( strftime(buffer, sizeof buffer, "%X", mytime) ) { printf("time1 = \"%s\"\n", buffer); } 问题在于此代码给出了一些随机时间。另外,随机时间每次都不同。我想要系统的当前时间。
97 c  time  time-t  localtime 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.