從In multi thread application how can i redirect stderr & stdout in separate file as per thread?延伸問題 看到一些如何保持所有printf和錯誤/警告消息在每個線程中產生在不同的日誌文件。 FILE * freopen (const char * filename, const char * mode,
請參閱下面的評論。 int main(){
//freopen("input.txt","r",stdin);//if I uncomment this line the console will appear and disappear immediately
int x;
cin>>x;
cout<<x<<endl;
system("pause
我正在嘗試使用文件重定向stdout和stderr的輸出。我正在使用freopen,它會在正確的目錄中創建文件,但文件是空白的。當我註釋掉重定向stdout和stderr的代碼時 - 輸出顯示在控制檯上。 下面是代碼: freopen(stderrStr.c_str(), "a+", stderr); //where stderrStr and stdoutStr are the path/fil