R
Rick N. Backer
Hello folks,
Novice type question here.
I'm working with a very simple app here that takes a series of strings
from the console. Once the end user has finished inputting the
strings they are individually processed and the result displayed back
to the console.
The problem I am having occurs during I/O redirection. Here is where
I am at the moment.
1) Run program with keyboard input and output redirected to file.
Never saw the prompt for the end user as it went straight to the
file. Fixed this, or so I thought, by having the end user prompt
displayed using cerr. Works like a charm, until we go to test
number 2.
2) Run program with both input and output being redirected. My user
prompt prints to the console before every line it accepts from the
input file. There are no problems with the output to the second
file from this operation. As my test suite consisted of ten
strings just to keep this simple one can see where, on large
files this behaviour would be annoying at the least but a big
performance hit no matter. I thought of using argc and argv but
when I/O redirection is in play it appears the argument count is
always 1 (program name) so is useless to me at this point.
My questions are:
Is the solution in problem 1 a reasonable approach to problem 1?
Given 1 works, how do I resolve the dilemma I now have at 2?
Thanks very much in advance.
Ken
Ken Wilson
Amer. Dlx. Tele, Gary Moore LP, LP DC Classic w/P90s,
Jeff Beck Strat, Morgan OM Acoustic,
Rick 360/12, Std. Strat (MIM), Mesa 100 Nomad,
Mesa F-30
"Goodnight Austin, Texas, wherever you are."
Novice type question here.
I'm working with a very simple app here that takes a series of strings
from the console. Once the end user has finished inputting the
strings they are individually processed and the result displayed back
to the console.
The problem I am having occurs during I/O redirection. Here is where
I am at the moment.
1) Run program with keyboard input and output redirected to file.
Never saw the prompt for the end user as it went straight to the
file. Fixed this, or so I thought, by having the end user prompt
displayed using cerr. Works like a charm, until we go to test
number 2.
2) Run program with both input and output being redirected. My user
prompt prints to the console before every line it accepts from the
input file. There are no problems with the output to the second
file from this operation. As my test suite consisted of ten
strings just to keep this simple one can see where, on large
files this behaviour would be annoying at the least but a big
performance hit no matter. I thought of using argc and argv but
when I/O redirection is in play it appears the argument count is
always 1 (program name) so is useless to me at this point.
My questions are:
Is the solution in problem 1 a reasonable approach to problem 1?
Given 1 works, how do I resolve the dilemma I now have at 2?
Thanks very much in advance.
Ken
Ken Wilson
Amer. Dlx. Tele, Gary Moore LP, LP DC Classic w/P90s,
Jeff Beck Strat, Morgan OM Acoustic,
Rick 360/12, Std. Strat (MIM), Mesa 100 Nomad,
Mesa F-30
"Goodnight Austin, Texas, wherever you are."