C++ 如何从控制台复制所有内容';输出到文本文件?
我曾尝试过使用Sink和SaveHistory来实现这一点,但都没有成功。我也试过一些方法,比如从一个答案中找到这个问题的代码。我在VisualStudio2019中用空的解决方案制作了所有内容 没有任何错误,但当我这样做时:C++ 如何从控制台复制所有内容';输出到文本文件?,c++,console,C++,Console,我曾尝试过使用Sink和SaveHistory来实现这一点,但都没有成功。我也试过一些方法,比如从一个答案中找到这个问题的代码。我在VisualStudio2019中用空的解决方案制作了所有内容 没有任何错误,但当我这样做时: ofstream myfile; myfile.open("Addresses.txt"); myfile << printf << endl; myfile.close(); return 0; 流myf
ofstream myfile;
myfile.open("Addresses.txt");
myfile << printf << endl;
myfile.close();
return 0;
流myfile的;
myfile.open(“Addresses.txt”);
MyFrase当你调用<代码> MyFrase:不相关的:<代码> MyFrime可能更简单,让C++在后面使用,并在命令行中使用重定向:<代码> MyStudio> MyField.txt< /Cord>
//Code I tried
#include <iostream>
using namespace std;
int main (int) {
cout << "This will print to the console!" << endl; // I don't know how to make it read all of the output
}
int x;
std::cin >> x;
std::cout << "You Entered: " << x << std::endl;