| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [C] An interesting question |
> Hi, there!
> Can anyone explain me, how and why sometimes in API's
> or userdefined functions, we use to declare (store) a
> character in an int datatype, or in other words ,
> store a char variable in an int storage ?? Many C
> API's like int getc(FILE *fp) , int putc(int c, FILE
> *fp)..... uses this concept, as return type of getc is
> char as explained in books(K&R) but declared as int ,
> again the param c in putc is char but defined as int..
> Can't we declare them as char instead of int ? How and
> why is this ?? Any one Please expalin me or point me
> to good references.
One reason is that the EOF character is (int) -1. Try putting that into
a char sized storage space, and all the functions that depend on it being
an int won't work.
Best Wishes,
Bill.
---
* Origin: Escan BBS (2:25/200)SEEN-BY: 633/267 270 @PATH: 25/200 108 252/110 250/501 140/1 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.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™.