getline() doesn't seem to work?
Adrian Miranda
ade@psg.com
Thu Jan 29 14:41:00 GMT 1998
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;
}
}
More information about the Gcc
mailing list