I need some help with an assignment. The lecturer gave us the following instruct
ID: 3529737 • Letter: I
Question
I need some help with an assignment. The lecturer gave us the following instructions:
Assuming that the input comes from a file such as this:
date: 1/13/2010
name: James Reed
amount, dollars: 45
cents: 30
payee: Home Depot
(You can save the file in your computer (cut-and-paste is acceptable) in file database.txt.) The output of your program should go to a different file named check.txt You may reuse the code from your earlier lab assignment. You may assume that in the input file, the fields are always named the same and the order of the fields is the same. However, the data fields of the file may change. That is, you may not program your assignment such that it only works with the provided example file.
I've gotten my code here: http://codepad.org/FVFj3QNh, I'm just not sure how to separate them so that the input becomes database.txt and the output becomes check.txt.
Explanation / Answer
Please rate with 5 stars :) All you need is this output redirection.
Output Redirection
The most common use of Redirection is to redirect the output (that normally goes to the terminal) from a command to a file instead. This is known as Output Redirection. This is generally used when you get a lot of output when you execute your program. Often you see that screens scroll past very rapidly. You could get all the output in a file and then even transfer that file elsewhere or mail it to someone.
The way to redirect the output is by using the ' > ' operator in shell command you enter. This is shown below. The ' > ' symbol is known as the output redirection operator. Any command that outputs its results to the screen can have its output sent to a file.