When I use freopen, and then redirect to the console,I can't see any output

Answered

When I use freopen, and then redirect to the console, I can't get any output.

#include <iostream>
using namespace std;
int main() {
freopen("../hello.txt", "w", stdout);
cout << "Hello" << endl;
freopen("CON", "w", stdout);
cout << "HELLO WORLD" << endl;
system("pause");
return 0;
}
1
1 comment

Hello!

You can try enabling the "Run in external console" option in your run/debug configuration (Run | Edit Configurations...), it should help.

0

Please sign in to leave a comment.