Is there a way to simulate: yourprogram < inputFile.txt
in Visual Studio 2008?
views:
995answers:
5Visual Studio is an IDE (= an embellished editor), not a programming language. What language/environment do you use?
The above causes the file inputFile.txt
to be streamed into the standard input stream of a program. All languages offer different mechanisms of accessing this stream and reading from it.
Assuming your looking to read from stdin
, you should have a glance at OpenStandardInput.
When you've developed your application (e.g. a ConsoleApplication) you would normally start this from the Command Line with
ConsoleApplication1.exe < inputfile.txt
The part of the command < inputfile.txt
is the command line arguments to your application.
You can set these in your project properties
- Right click the project file
- Click
properties
- Click the
Debug
tab In the Start Options section enter
< Path/To/inputfile.txt
When you next launch your application with the debugger, it will execute your application with these Command line args
- In the menu at the top click Project, then Properties (bottom option)
- In the " Property Pages" window, expand "Configuration Properties", on the left
- choose "Debugging", on the left
- in the "Command Arguments" field, on the right, type "< inputFile.txt"
When you do this, notice at the top of the Property Pages window you have selected the current Configuration and Platform. So if you change configuration(e.g. from "debug" to "release"), suddenly these options don't apply, and you'll have to go back to this properties window to set these configs for that configuration/platform.
Also, this only seems to apply when you run using "Start without Debugging" (F5) and not when using "Start Debugging" (Ctrl + F5). I would think there's some way to have an input file work w/ Ctrl+F5, but I haven't found it yet.