c++ - 如何将我编写的程序应用到我编写的文件(C++)中的不同输入?
问题描述
我希望我的 C++ 程序读取我在 .txt 文件中编写的所有输入,并向我显示我想要的每个输入的输出。我基本上希望程序在我的每个输入上运行,相反,它只读取我的第一个输入。我希望它为我提供的每组信息循环。这是我到目前为止所拥有的:
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;
int main()
{
ifstream fin;
ofstream fout;
fin.open("emp.txt");
fout.open("output.dat");
string last, first;
double salary, increase, nsalary;
while (fin>>last>>first>>salary>>increase);
{
nsalary= salary + ((salary/100.0)*increase);
fout<<first<<"\t"<<last<<"\t"<<fixed<<showpoint<<setprecision(3)<<salary<<"\t\t"<<nsalary;
cout<<first<<"\t"<<last<<"\t"<<fixed<<showpoint<<setprecision(3)<<salary<<"\t\t"<<nsalary;
fin.close();
fout.close();
}
}
谢谢
解决方案
推荐阅读
- sql-server - SQL Server Management Studio 从 Oracle BadImageFormatException 导入数据
- javascript - 迭代对象
- javascript - Highcharts:使用相同数据更新多个图表上的系列
- rest - Angular 6 到 Spring 引导休息服务 CORS 问题
- matlab - Matlab:将像素值强制为与掩码中的非零相对应的 NaN
- node.js - node server.js 可以工作,但 npm start 不能
- winforms - 如何使用 Visual Studio 设计器在 Winforms 中设置数据绑定
- javascript - JavaScript 变量在函数内部没有正确定义
- excel - 在一个循环中循环数年和数月
- powershell - 如何在 PowerShell 中进行条件替换?