Mail Archives: djgpp/2000/04/11/16:17:25
On Tue, 11 Apr 2000, Bharat Mallapur wrote:
> in short i want to know that how is it that gcc which is supposed to be
> "totally" ansi/iso compliant not have getchar which is a standard library
> function.
I think you misunderstood what the GCC maintainers told you. What
they tell you is that the library you are using is a separate product:
it was written specifically for the DJGPP project. The compiler
itself comes with no library.
In other words, the GCC maintainers simply told you that you were
posting your question to the wrong news group. See section 20.1 of
the DJGPP FAQ list for more about this.
> The fact is i decided to download djgpp only after being told on comp.lang.c
> that it is a fully ansi/iso compliant compiler and of course that it is
> free.
> So now please tell me whether djgpp is ansi/iso C compliant or not.
DJGPP is ANSI/ISO compliant, at least as far as the C89 standard is
concerned (in contrast, C99 is not fully supported yet).
>>My problem is the following:
>>============================
>>/*
>> Problem : Non leading EOF is ignored by getchar().
>> Triggering :
>> Try TYPING IN the 3 following lines when running the program:
>> "a ^Z the" enter/return
>> " ^Z the" enter/return
>> "^Z the" enter/return
>> (here ^Z gives EOF and is same as Ctrl+Z)
This is not a bug. (It certainly isn't an ANSI compatibility issue,
since the ANSI standard doesn't say anything about the ^Z character.)
The problem with your program is that it uses (the default) buffered
I/O to read single characters from the console device. In buffered
operation, the DJGPP library removes the ^Z characters from the
stream, so that they don't end up in the application buffer. That's
why you don't see the EOF where you expect it.
The simplest change that will make your program behave as you want is
to add the following line before the loop:
setvbuf (stdin, NULL, _IONBF, 0);
- Raw text -