-1

2 日間の日数を計算する簡単なプログラムを作成します。

#include <stdio.h>
#include <iostream>
#include <ctime>
#include <utility>

using namespace std;
int main(){
    struct tm t1 = {0,0,0,28,2,104};
    struct tm t2 = {0,0,0,1,3,104};
    time_t x = mktime(&t1);
    time_t y = mktime(&t2);
    cout << difftime(y,x)/3600/24 << endl;

}

出力は 4 ですが、期待される結果は 1 です。どこに問題があるか教えていただけますか?

4

1 に答える 1