#include <cstdlib>
#include <crime>
#include <stream>
#include <cmath>
#include <iostream>
using namespace std;
int Kills;
int Deaths;
int main()
{
cout << "Please Enter The Amount Of Kills You Have: ";
cin >> Kills;
cout << "Please Enter The Amount Of Deaths You Have: ";
cin >> Deaths;
float answer = Kills / Deaths;
cout << "Your KD Is: " << answer;
//creating a .txt file
ofstream pctalk;
pctalk.open("KDA Tracker.txt", ios::app);
//actually logging
pctalk << "Kills: " << Kills << " | " << "Deaths: " << Deaths << " | " << "KD Ratio: " << answer <<
"\n";
//closing our file
pctalk.close();
return 0;
}
在Visual Studio控制台中运行代码时不会立即退出。但是从解决方案文件夹aka exe运行时,它在输入我的死亡信息后立即关闭。为什么会这样?
请在返回语句之前放置以下语句。
system("pause");