HorseloverFat
HorseloverFat

Reputation: 3326

Redirect C++ output stream to a file in VS 2010 without changing code?

At the command prompt I might compile my program and then run as follows:

myprogram > output.txt

Is there a similar way of redirecting the output stream in VS2010? I want to debug/run my program within the IDE but have cout stream to a file.

Upvotes: 1

Views: 350

Answers (1)

nullpotent
nullpotent

Reputation: 9260

Just redirect the stdout stream pointer.

freopen( "file.txt", "w", stdout );

Upvotes: 7

Related Questions