私は自分のクラス用にこのコードを書きました。デバッグすると実行されますが、数秒以内にシャットダウンします。ここで何が間違っているのかわかりません。私は本当にC ++が初めてです。
コードは次のとおりです。
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double gallons;
double startmile;
double endmile;
double totalmilestravelled;
cout << "This Program Calculates your vehicle's gas mileage on this trip\n" << endl;
cout << "What is the number of gallons consumed on the trip: ";
cin >> gallons;
cout << "\nWhat was your ending mile?";
cin >> endmile;
cout << "\nWhat was your starting mile?";
cin >> startmile;
totalmilestravelled = endmile-startmile;
double mpg = totalmilestravelled/gallons;
cout << "your gas mileage is: " << mpg << endl;
return 0;
}
これがエラーです: プログラム '[9848] gasmileage.exe: Native' はコード 0 (0x0) で終了しました。