Discussion:
Reading from cin.... how to stop??
(too old to reply)
THOM BOHK
2011-06-11 21:46:50 UTC
Permalink
Alright, so if no input file is specified, we read from cin.

I'm assuming, then, the user should be able to input an arbitrarily
long chunk of input where some lines are #include directives, specify
an end to his/her input, and have that chunk of input be processed the
same way a specified input file would.

How can the user specify that they are done their input, so that it
can be passed of to processOneFile? ctrl-D for EOF exits the include
program, so that's no good....

the only real solution I can see is that user input can be of one line
with an include directive on it?
THOM BOHK
2011-06-11 22:07:51 UTC
Permalink
Post by THOM BOHK
Alright, so if no input file is specified, we read from cin.
I'm assuming, then, the user should be able to input an arbitrarily
long chunk of input where some lines are #include directives, specify
an end to his/her input, and have that chunk of input be processed the
same way a specified input file would.
How can the user specify that they are done their input, so that it
can be passed of to processOneFile? ctrl-D for EOF exits the include
program, so that's no good....
the only real solution I can see is that user input can be of one line
with an include directive on it?
Alright from playing with the given executable I guess I've answered
my own question.. it just reads stdin until it sees an include
directive and it does the whole include on it and continues to accept
input, and program is exited by EOF (ctrl-D). Not what I expected from
the assignment's problem description.
John Munnings
2011-06-12 18:07:38 UTC
Permalink
Post by THOM BOHK
Post by THOM BOHK
Alright, so if no input file is specified, we read from cin.
I'm assuming, then, the user should be able to input an arbitrarily
long chunk of input where some lines are #include directives, specify
an end to his/her input, and have that chunk of input be processed the
same way a specified input file would.
How can the user specify that they are done their input, so that it
can be passed of to processOneFile? ctrl-D for EOF exits the include
program, so that's no good....
the only real solution I can see is that user input can be of one line
with an include directive on it?
Alright from playing with the given executable I guess I've answered
my own question.. it just reads stdin until it sees an include
directive and it does the whole include on it and continues to accept
input, and program is exited by EOF (ctrl-D). Not what I expected from
the assignment's problem description.
There seems to be a bit of confusion so I'll try to give a bit better of
an explanation. The user can enter arbitrary lines of input, and specify
when they are done their input, and it does get processed. The ctrl-D
command does signal the end of user input, it's just that the executable
has nothing more to do once the file has been processed and it exits
immediately.

I think the stumbling block is that the whole time it is accepting input
it is processing the file, instead of trying to process the entire thing
once it has found the end. I'll leave it to you to see why it might do
this and why that might make things easier.

Loading...