我想在 c++
中使用 printf 打印一行 int t0 = time(NULL);
int outIndx = 99736;
printf ("time using recurision = %d secs, the result is = %d\n",(time(NULL) - t0), outIndx);
在这种情况下,printf 的输出是:
使用递归的时间 = 0 秒,结果为 = 0
但是当颠倒outIndx和(time(NULL) - t0)的顺序时:
printf ("time using recurision = %d secs, the result is = %d\n", outIndx,(time(NULL) - t0));
printf 的输出被正确打印:
使用递归的时间 = 99736 秒,结果为 = 0
为什么会这样?
最佳答案
time
返回一个 time_t
,它的大小不必与 int
相同。在这种情况下,%d
不是正确的输出格式。
关于c++ - printf 对参数的顺序敏感吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34411303/