getchar returns int not char. You need to store the value as an int to test against EOF because EOF is defined as an int (normally with the value of -1).
If you converted the value of getchar to a char before comparing to EOF you would have trouble in 1 of 2 ways
On systems with default signed char you would be unable to distinguish between the character value 0xFF and EOF because 0xFF is -1 in 8 bits.
On systems with default unsigned char you would never see the EOF because when getchar returned EOF (-1 in 16 or 32 bits 0xFFFFFFFF) it would be truncated to 0xFF. Then 0xFF would be converted to int for the comparison resulting in the value 255 and 255 is != -1 so you would loop forever.
It is more than perferable for c to be an int, it is essential.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...