I'm using VS 2010, and I'm wondering how I can get my c++ program to read a file using standard input while debugging. I know how to do it from command prompt, but not when debugging.
Basically I want it to read in a file with cin>> instead of me typing stuff - but in debug mode.
Right-click on the project in the Solution Explorer and go to Properties. Then click on "Debugging" on the left and in the "Command Arguments" box type something like
< input.txt
If you go into the project's Properties, under Debugging there's a set of options for how to actually launch the process. IIRC the way to do this is to put:
In the Command Arguments box.
I've never tried this (I'll usually have a debug path that accepts input from a file), but this MS Connect bug report claims that redirection operators worked in VS2005 but stopped working in VS2008:
MS claims to have fixed the problem at some point, so maybe it's working again in 2010?