我發現這個問題的回答爲Python,Java和Linux的腳本,而不是C++:寫入到兩個終端和文件C++
我想寫我的C的所有輸出++程序,終端和輸出文件。使用這樣的事情:
int main()
{
freopen ("myfile.txt","w",stdout);
cout<< "Let's try this";
fclose (stdout);
return 0;
}
其輸出到唯一的命名爲「myfile.txt的」輸出文件,並防止其表示在終端上。我怎樣才能使它同時輸出?我使用visual studio 2010 express(如果這會產生任何影響)。
在此先感謝!
您使用不同的流對象,其中一個重複調用的文件,併到stdout [自定義C++的cout類 – StoryTeller
可能重複 - outpu t到控制檯和日誌文件](http://stackoverflow.com/questions/5942229/custom-c-cout-class-output-to-both-console-and-log-file) – feetwet