CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    254

    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?

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    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
    Last edited by Alex F; July 12th, 2010 at 03:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured