#ifndef UNICODE
#define UNICODE
#endif
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <Windows.h>
int main()
{
char buffer[30];
int counter=0;
for(int i=0; i<22 ; i++)
{
Sleep(1000);
printf("%d %d\n",counter++,time(0));
}
system("pause");
return 0;
}
このバージョンは問題なく動作し、カウンターと過去 22 秒間のタイムスタンプを出力します。残念ながら、私が一見無関係なことをしたとき - counter と time(0) を置き換える、つまりprintf("%d %d\n",time(0),counter++);
、関数は常に counter の代わりに 0 を出力しました! この奇妙な事実の説明はありますか?