C++如何将想要的结果输出到指定路径的txt

2026年09月08日 23:38
有4个网友回答
网友(1):

用fstream就可以做到了:

ofstream ofs("target.txt", ios::out);
ofs<<"你想输入的内容";

网友(2):

#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 = " <

网友(3):

看看文件输入输出流就知道了。

网友(4):

C++用fstream