用fstream就可以做到了:ofstream ofs("target.txt", ios::out);ofs<<"你想输入的内容";
#include #include using namespace std;int main(){ int x = 0; int y = 0; ofstream fileSave("d:\\fileSave.txt"); if(!fileSave)return; for(x = -20;x<20;x++) { y = x*x; cout << " x = " <
看看文件输入输出流就知道了。
C++用fstream