Jim said:
Does anyone know why K&R2 uses the term "File Copying" at this point
(1.5.1)?
Also, in the K&R2 answers to exercises maintained by Richard Heathfield,
for Listing KRX113 Mr Heathfield repeatedly uses the phrase "text file".
This comes well before what I have understood to be "files" are
introduced in the book.
Reading Stephen Prata's "C Primer Plus", in chapter 8 "Redirection and
Files", I found:
"Unix, Linux, and current DOS versions enable you to redirect both input
and output. Redirecting input enables your program to use a file instead
of the keyboard for input, and redirecting output enables it to use a
file instead of the screen for output."
So to get the program to use a text file as input I would use:
"my_program < text_file"
This is the answer I was looking for. I thank Santosh and Richard
Heathfield for taking the time to reply to my question.
Talking about this with a co-worker today, I learned more about OUTPUT
redirection. If I use "my_program > output_file" the "output_file" will
be created or, if it already exists, will be overwritten. If I use TWO
redirection symbols (">>") then the output from "my_program" will be
appended to "output_file" (assuming it already exists).
I already knew about simple redirection but failed to connect it with
the problem I was having with the K&R examples and exercises. I hope
this helps other newbies learning C using K&R2.