If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: C: getchar

When you do:

Code:

while( i = getchar() != EOF )

You are really doing:

Code:

while( i = ( getchar() != EOF ) )

So, it gets the character, compares it against the EOF character. It's most likely not equal to it, and so that boolean will become 1 and get assigned to i. This happens because the != operator has a higher precedence than the assignment operator.

Re: C: getchar

There is another problem with your code.
EOF is usually defined as the int -1. If you assign it to a char then the value will be truncated and the test will never be true.
BTW that is the reason why getchar() returns an int and not a char.
Kurt

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.