实现的功能是让输出终端(即显示器)输出编译器中的内容。。。。
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
struct SalaryInfo{ unsigned id;
double salary;
};
int main()
{ SalaryInfo employeel={600001,80000};
ofstream os("c:\\1.txt",ios_base::out|ios_base::binary);
os.write(reinterpret_cast<char*>(& employeel),sizeof( employeel));
os.close();
ifstream is("D:\\编程文件\\main.cpp",ios_base::in|ios_base::binary);
if(is){ char ch;
while((ch=is.get())!=EOF)
cout.put(ch);
}
is.close();
system("pause");
}
本文展示了如何使用C++将编译器生成的内容输出到文件,并通过读取文件将其显示在终端上。
1670

被折叠的 条评论
为什么被折叠?



