Is there a way to simulate: yourprogram < inputFile.txt
in Visual Studio 2008?
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.
Visual 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.
I can give you an answer for C++ (at least) in project properties: Configuration Properties -> Debugging in Command arguments: inputfile.txt and make sure the working directory is the same as the one the file is in
I just discover how to make it work with Ctrl + F5. Just put the inputFile.txt on the same folder of your .exe of the project
Keep your test data input file in Project working directory where *.cpp file is present Right click on Project->properties->Configuration properties ->debugging
In Debugging, click on command Arguments tab and add following line
< Your_project_directory_path\input.txt
© 2022 - 2024 — McMap. All rights reserved.