Like Tree1Likes
  • 1 Post By Elkvis

Dumb this down

This is a discussion on Dumb this down within the Tech Board forums, part of the Community Boards category; Can someone please dumb down this question for me? Write the command that would type in on the command line ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    14

    Dumb this down

    Can someone please dumb down this question for me?

    Write the command that would type in on the command line to run the program called Q19.exe. Use redirection so the input to the program comes from a file named Input.txt and the output from the program is saved to the file named Results.txt.

    I do not really understand what this is telling me.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,207
    Note for mods: this is not a C++ question in any shape or form. I belongs elsewhere.

    Let's say you have a program called Q19.exe that reads from standard input (eg console, keyboard) with writes to standard output. How would you run that program if you wanted it to read data from a file called Input.txt and write results to Results.txt?
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    14
    Hello grumpy:

    What do you mean "this is not a c++ question in any shape or form".

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,207
    Exactly what I said. The question was about how to run a program while redirecting input and output. The techniques to do that are operating system (or shell aka command line interpreter) specific, and have nothing whatsoever to do with C++.

    If you've been given this question in a C++ course, the intent is probably that you use the system() function. But the string you will need to supply to the system call will be specific to your host systems.

    If a teacher of a C++ course has given this question without any mention that the solution is operating system specific then, frankly, my advice is to find another teacher. (There are sometimes reasons to do such things in a course like "C++ programming for windows" but, even then, it is lousy technique that will make potential employers look at you askance).
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    21
    As grumpy said, this question is language agnostic. As it is referring to OS redirection of the standard input/output.
    The solution is simple; in windows, you can run the program like this:
    Code:
    q19.exe <Input.txt> results.txt
    This will simply redirect the standard input/output to read and write information to a file instead of the console. That means that operations such as std::cin >> x and std::cout << x will read x from Input.txt and write its value on results.txt. It's important to notice that the input and output text files must be in the same directory as the executables and can have any name, not necessarily "input.txt" and "output.txt".

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    2,294
    Do not hand out answers!!! how is he supposed to learn how or why this works if you just give it to him on a silver platter?!
    cyberfish likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Im so dumb
    By ytaipsw in forum C++ Programming
    Replies: 9
    Last Post: 12-16-2006, 03:16 PM
  2. am I dumb?
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 01-30-2003, 05:42 PM
  3. I am so dumb
    By face_master in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-09-2002, 08:04 PM
  4. Was I really that dumb?
    By face_master in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 09-14-2002, 08:02 PM
  5. Im new and dumb :)
    By Prodigy in forum C++ Programming
    Replies: 1
    Last Post: 05-04-2002, 11:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21