Reading file input in Visual Studio 2008

Is there a way to simulate: yourprogram < inputFile.txt in Visual Studio 2008?

+3
source share
7 answers

When you have developed your application (e.g. ConsoleApplication), you usually start it from the command line with

 ConsoleApplication1.exe < inputfile.txt 

Part of the < inputfile.txt command is the command line arguments for your application.

You can set them in your project properties.

  • Right click project file
  • Click properties
  • Go to the Debug tab
  • In the "Launch Options" section, enter

     < Path/To/inputfile.txt 

The next time you launch the application using the debugger, it will execute your application using these command line arguments

+6
source
  • In the menu at the top, click "Project", then "Properties" (bottom option)
  • In the Property Pages window, expand Configuration Properties on the left.
  • select "Debug" on the left.
  • in the "Command Arguments" box on the right, enter "<inputFile.txt"

When you do this, note that at the top of the Property Pages window, you have selected the current configuration and platform. Therefore, if you change the configuration (for example, from "debug" to "release"), suddenly these parameters are not applied, and you need to return to this properties window to set these configs for this configuration / platform.

Also, this only seems to be applicable when you start “Start without debugging” (F5), and not when using “Start debugging” (Ctrl + F5). I would think that there is a way to work with the input file w / Ctrl + F5, but I have not found it yet.

+4
source

Visual Studio is an IDE (= decorated editor), not a programming language. What language / environment do you use?

The above leads to the inputFile.txt file inputFile.txt to the standard program input stream. All languages ​​offer various mechanisms for accessing and reading from this stream.

+1
source

Assuming you want to read with stdin , you should take a look at OpenStandardInput .

0
source

I can give you an answer in C ++ (at least) in the project properties: Configuration Properties → Debugging in the command arguments: inputfile.txt and make sure that the working directory is the same as the file located in

0
source

I just learn how to make it work with Ctrl + F5. Just put the inputFile.txt file in the same folder of your .exe project

0
source

Save the test data input file in the working directory of the project, where the * .cpp file is present Right-click Project-> properties-> Configuration Properties → debugging

In the Debug section, go to the Arguments tab and add the following line

<Your_project_directory_path \ input.txt

0
source

All Articles