help with one minor error

This is a discussion on help with one minor error within the C++ Programming forums, part of the General Programming Boards category; Naughty!.. what's this?.. int choice = 0; And you're trying to input a character right? Well, you must replace int ...

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Naughty!.. what's this?.. int choice = 0;
    And you're trying to input a character right?

    Well, you must replace int choice = 0; with char choice = 'x';
    No, actually, you should use 'int' here. All of the 'is*( )' functions, all of the 'getc' and 'putc' functions take integers as arguments, and return integers as return values. Additionally, if you're reading from a file, the EOF value is outside a 'char', so you have to read into an int to get the correct end result. As such, yes, use 'int'.

    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I figured out about the variable being an 'int' instead of a 'char' or 'string' on my own, but thanks anyway.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21