Question about the getchar() and eof !!!...

J

Jordan Abel

How so? If you're referring to the assumption of an ASCII character
set, that makes it non-portable, not completely wrong. (For that
matter, code 65 is ascii 'A', even if some particular implementation
doesn't use ASCII -- though that's admittedly a bit of a stretch.)

If UCHAR_MAX is very large, the conversion to unsigned char may not
yield 65.

Apart from that, it seems ok.

Perhaps you'd care to expand on that a bit?

I actually thought for some reason that it was undefined if the value is
outside the range of unsigned char, just like with other functions that
take an int that is meant as an unsigned char value [for example, is*()]
 
P

Pedro Graca

Keith said:
C99 7.19.2p2: [...]

So if you write a control character (other than horizontal tab and
new-line) to a text file, all bets are off.

Ok. Thank you for fishing the relevant paragraph from the Standard.
 
M

Mark McIntyre

It /must/ have an integer value. A negative one. Of type int. See 7.19.1#3.

Thanks for clarifying that. I was thinking in the context of how
printf handles it rather than how the macro was defined.
Mark McIntyre
 
M

Mark McIntyre

it converts '\x1A' to an EOF condition for input, discarding that
particular character and all the following ones (and yet it allows one
to output as many '\x1A's as one wants to ...)

... Stupid Windows

I suspect that *nix* and VMS will do much the same, if trained
properly.
Mark McIntyre
 
R

Ravi Nakidi

Hi Neras,

getchar() is a function which takes the input without any enter key.

Say for example, I entered:
1
enterkey
2
enterkey
3
enterkey
ctrl+z and enter

ok
now come to output: first input 1
1 !=EOF
then nc=1
then
enter key
enterkey != EOF
then nc = 2

;
;
;
nc=4
then ctrl+z and enterkey. it is nothing but EOF(End Of File)
so, while condition fail.
Program will come out.

Regards,
Ravi Nakidi,
S/w Engineer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top