c++文件输入输出~

来源:百度知道 编辑:UC知道 时间:2024/06/23 15:59:21
程序没有语法错误,可是就是输出的结果不是自己想要的...高手帮忙解决啊~~~本人新手...
#include <fstream>
#include <iostream>
int main()
{
using namespace std;
ifstream in_stream;
ofstream out_stream;

in_stream.open("infile.txt");
int a,b,c;
out_stream.open("outfile1.txt");
cin>>a>>b>>c;
out_stream<<a<<b<<c<<endl;
in_stream.close();
out_stream.close();

in_stream.open("outfile1.txt");
out_stream.open("outfile2.txt");
int first,second,third;
in_stream>>first>>second>>third;
out_stream<<"The sum of the first 3\n"
<<"numbers in infile.dat\n"
<<"is "<<(first+second+third)
<<endl;
in_stream.close();
out_stream.close();

in_stream.open("outfile2.txt");
char a1[30],

#include <fstream>
#include <iostream>

using namespace std;
int main()
{
using namespace std;
ifstream in_stream;
ofstream out_stream;

in_stream.open("infile.txt");
int a,b,c;
out_stream.open("outfile1.txt");
/*cin>>a>>b>>c; */
in_stream>>a>>b>>c; //修改
out_stream<<a<<" "<<b<<" "<<c<<" "<<endl; //修改
in_stream.close();
out_stream.close();

in_stream.open("outfile1.txt");
out_stream.open("outfile2.txt");

int first,second,third;
in_stream>>first>>second>>third;
out_stream<<"The sum of the first 3\n"
<<"numbers in infile.dat\n"
<<"is "<<(first+second+third)
<<endl; <