This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: getline() doesn't seem to work?


Adrian Miranda <ade@psg.com> writes:

> I am using egcs 1.0.1 on HP-UX 10.20.
> 
> I don't know if this is a bug in getline, or just a bug in my
> understanding of getline.  When I have the following program just
> reading from my terminal, I have to hit control-D twice before the
> loop exits.  It appears that the first time I hit control-D, getline
> does not even return, it's only when I hit CONTROL-D a second time
> that getline returns false, and the loop exits.
> 
> 
> #include <iostream.h>
> main() {
>     char word[100];
>     while(cin.getline(word, 100, '\n')) {
>         cout << "Got another line" << endl;
>     }
> }

Same thing happens on my linux machine.

Joe Buehler


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]