TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: all
from: Jay Truesdale 72176,3565
date: 1990-10-27 12:20:22
subject: #OSK C

#: 7798 S3/Languages
    27-Oct-90  12:20:22
Sb: #OSK C
Fm: Jay Truesdale 72176,3565
To: all

OK, I must be confused!  The C book I am using shows something like this:

    while( (ch=getchar()) |='Y' && ch |='y' && ch |= 'N' && ch |= 'n')
      printf("Please enter a Y or a N\n");

"ch" is defined like this:

  int ch;

As I understand it, getchar returns an integer so this should be ok.

When I compile this with the MW OSK C compiler I get:

"prog9.c", line 59: ****  lvalue required ****
    while( (ch=getc((&_iob[0]))) |='Y' && ch |='y' && ch |= 'N' && ch |= 'n')
              ^

and this continues for each ocurrence of "ch" in the statement.  The error 
messages in the C manual state that this means that the item to the left of 
the assignment operator must be able to be stored into.  I thought you could 
store a char into an int.

So what obvious fact am I overlooking this time?

-J


There are 3 Replies.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.