Visual Studio Command Line
I'm using Visual Studio 2010, so technically this seems the best forum to ask my question. If I run a console app from the dos command line, I can redirect the input to come from a text file, which cin will operate on, for example:
app < data.txt
However, I don't like to use the command line, and so am wondering how to redirect input using the Visual Studio property page. Going to Configuration Properties--> C/C++ --> Command Line and typing: < data.txt into the additional options box results in 2 problems, the first being that '<' is not recognized as a valid command, and that the file 'data.txt' is not found. The file is in the same directory as the executable, and I have no problem running the program from the console.
So what do I have to put in the Additional Options box, and where should I put the data file?
Re: Visual Studio Command Line
Output redirection is cmd.exe program feature. Other programs don't understand this syntax. You may try to call cmd.exe from Visual Studio. For example, execute this command using the Windows Run function:
cmd.exe /C dir > c:\dir.txt
File c:\dir.txt is created.
You can execute your own program with redirection from Visual Studio, instead of running the program directly. Change the "Command" value in Configuration Properties to:
cmd.exe /C $(TargetPath) > data.txt