Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Redirection in Visual studio

Redirection in Visual studio

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocsharpc++debuggingquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hain
    wrote on last edited by
    #1

    I have a console C++ application that reads standard input and writes standard output. I want to run (i.e., debug) the program under the IDE, using a text file that I want to redirect to the program, and want the output to redirect to (over)write a text file. Going to the project properties, and under "Comand Arguments" typing "out.txt" (without the quotes) does not work. Neither does "<..\in.txt >..\out.txt" What am I doing wrong? Thanks! Tom

    D 1 Reply Last reply
    0
    • H hain

      I have a console C++ application that reads standard input and writes standard output. I want to run (i.e., debug) the program under the IDE, using a text file that I want to redirect to the program, and want the output to redirect to (over)write a text file. Going to the project properties, and under "Comand Arguments" typing "out.txt" (without the quotes) does not work. Neither does "<..\in.txt >..\out.txt" What am I doing wrong? Thanks! Tom

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Do you have something similar to the following in your code:

      fread(..., stdin);
      fwrite(..., stdout);

      If so, can you implement something like this instead:

      FILE *in;
      FILE *out;

      if (argc == 1)
      {
      in = stdin;
      out = stdout;
      }
      else
      {
      in = fopen(argv[1], "r");
      out = fopen(argv[2], "w");
      }

      fread(..., in);
      fwrite(..., out);

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      H 1 Reply Last reply
      0
      • D David Crow

        Do you have something similar to the following in your code:

        fread(..., stdin);
        fwrite(..., stdout);

        If so, can you implement something like this instead:

        FILE *in;
        FILE *out;

        if (argc == 1)
        {
        in = stdin;
        out = stdout;
        }
        else
        {
        in = fopen(argv[1], "r");
        out = fopen(argv[2], "w");
        }

        fread(..., in);
        fwrite(..., out);

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        H Offline
        H Offline
        hain
        wrote on last edited by
        #3

        Thanks, David, but that's not the problem. The program works from the command line, e.g.,

        prog.exe <in.txt >out.txt

        What I want to know is how do you set this up within Visual studio? I would have thought setting up the command arguments from within VS would do the trick--but I have not figured it out. Again, thanks, Tom

        D 1 Reply Last reply
        0
        • H hain

          Thanks, David, but that's not the problem. The program works from the command line, e.g.,

          prog.exe <in.txt >out.txt

          What I want to know is how do you set this up within Visual studio? I would have thought setting up the command arguments from within VS would do the trick--but I have not figured it out. Again, thanks, Tom

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          hain wrote:

          The program works from the command line, e.g., prog.exe out.txt What I want to know is how do you set this up within Visual studio?

          Given this scenario, just add out.txt to the Program Arguments box in the project's settings.

          "Love people and use things, not love things and use people." - Unknown

          "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

          H 1 Reply Last reply
          0
          • D David Crow

            hain wrote:

            The program works from the command line, e.g., prog.exe out.txt What I want to know is how do you set this up within Visual studio?

            Given this scenario, just add out.txt to the Program Arguments box in the project's settings.

            "Love people and use things, not love things and use people." - Unknown

            "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

            H Offline
            H Offline
            hain
            wrote on last edited by
            #5

            Apparently the rendering of the code was not right in my last message. What I want to do (from within VS) is prog.exe <in.txt >out.txt where < and > are the redirection symbols.

            D 1 Reply Last reply
            0
            • H hain

              Apparently the rendering of the code was not right in my last message. What I want to do (from within VS) is prog.exe <in.txt >out.txt where < and > are the redirection symbols.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              You can't do that within the IDE.

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              H 1 Reply Last reply
              0
              • D David Crow

                You can't do that within the IDE.

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                H Offline
                H Offline
                hain
                wrote on last edited by
                #7

                Hmmm... I'm very surprised/disappointed. Thanks, Tom

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups