views:

995

answers:

5

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

+1  A: 

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.

Konrad Rudolph
+1 for interesting definition of IDE ! ;-)
Cerebrus
Darn, got disconnected!
Cerebrus
A: 

Assuming your looking to read from stdin, you should have a glance at OpenStandardInput.

Ryan Emerle
+2  A: 

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

Eoin Campbell
I can't seem to find the Start Options... I'm on the project's properties page and under configuration properties I have a Debugging field...
Epsilon Vector
Eoin Campbell
A: 

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

A: 
  • 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.

WillDeStijl