主题:文件错误:各位大侠,此程序是关于文件不能存进数据的编程
为什么此程序不能存进文本文件中数据。在输入时,为什么不执行输入。
#include "iostream"
#include "fstream"//编写一条语句在该程序中包含头文件fstream
#include "iomanip"
#include "string"
using namespace std;
void main()
{
ifstream inFile;//第二个问题
ofstream outFile;//第二个问题
int a1,b1,a2,b2;
char studentId;
inFile.open("F:/VC/zizhukaifa/zhzhr2/inData.txt",ios::in);
if(!inFile)
cout <<"没有被打开!";
outFile.open("F:/VC/zizhukaifa/zhzhr2/outData.txt");
outFile << fixed << showpoint;
outFile << setprecision(2);
cout << "Processing data" << endl;
//编写一条语句,在程序招待一,文件OUTdATA.DATR、的内容如下所示。如果需要,可以声明额外的变量
//语句应该足够通用,这样如果输入文件的内容修改并且程序再次运行时,它还可以输出适当的结果
inFile >> a1;
inFile >> b1;
inFile >> studentId;
inFile >> a2;
inFile >> b2;
outFile << "shuchu jieguo:" << endl;
outFile << "Sum of "<< a1 << "and " << b1 << "=" << a1+b1;
outFile << "The character that comes after A in the ASCII set is B."
<< endl<< "The product of " << a2 << "and " << b2 << "=" << a2 * b2;
inFile.close();
outFile.close();
}
#include "iostream"
#include "fstream"//编写一条语句在该程序中包含头文件fstream
#include "iomanip"
#include "string"
using namespace std;
void main()
{
ifstream inFile;//第二个问题
ofstream outFile;//第二个问题
int a1,b1,a2,b2;
char studentId;
inFile.open("F:/VC/zizhukaifa/zhzhr2/inData.txt",ios::in);
if(!inFile)
cout <<"没有被打开!";
outFile.open("F:/VC/zizhukaifa/zhzhr2/outData.txt");
outFile << fixed << showpoint;
outFile << setprecision(2);
cout << "Processing data" << endl;
//编写一条语句,在程序招待一,文件OUTdATA.DATR、的内容如下所示。如果需要,可以声明额外的变量
//语句应该足够通用,这样如果输入文件的内容修改并且程序再次运行时,它还可以输出适当的结果
inFile >> a1;
inFile >> b1;
inFile >> studentId;
inFile >> a2;
inFile >> b2;
outFile << "shuchu jieguo:" << endl;
outFile << "Sum of "<< a1 << "and " << b1 << "=" << a1+b1;
outFile << "The character that comes after A in the ASCII set is B."
<< endl<< "The product of " << a2 << "and " << b2 << "=" << a2 * b2;
inFile.close();
outFile.close();
}