Getting my char command to work!!!

This is a discussion on Getting my char command to work!!! within the C++ Programming forums, part of the General Programming Boards category; I put in the following code. #include <iostream.h> #include <string.h> #include <ctype.h> #define max 30 char choice(max); int main() { ...

  1. #1
    Registered User CumQuaT's Avatar
    Join Date
    Sep 2001
    Posts
    73

    Unhappy Getting my char command to work!!!

    I put in the following code.

    #include <iostream.h>
    #include <string.h>
    #include <ctype.h>
    #define max 30


    char choice(max);
    int main()
    {
    cout << "(L)eft or (R)ight?" << endl;
    cin >> choice;

    return 0;
    }

    And I keep getting the error message

    Cannot change from CHAR(30) to CHAR (5)

    What the hell is going on!!!???
    Why? The often unanswerable question. If it is unanswerable, why answer it?

    Join the Cult of Sheograth, it's the place to be!

    http://cultosheogorath.proboards16.com

    Lord, we know what we are, yet we know not what we may be... Who wrote that anyway? If you know, E-Mail me. mr_shnokovitz@yahoo.com

    Joy to all the fishes...

    **infected by frenchfry164**

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    What's your compiler? I tried compiling it in Dev C++ 4.0 and it compiled with no errors. The problem may lie within your compiler, then again (as usual) I could be wrong...

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    ...I thought of a way that *may* solve the problem. try this variations or your code (not that I can see anything wrong with your current code at the moment)...

    Code:
    #include <iostream.h> 
    #include <string.h> 
    #include <ctype.h> 
    
    int main()
    {
    int MAX = 30;
    char choice(max);  
    cout << "(L)eft or (R)ight?" << endl; 
    cin >> choice; 
    
    return 0; 
    }

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    If choice is supposed to be a charater array rather than a function (which I presume is the case) then it should be declared like this -

    char choice[max];

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    oops

    missed that error, though how simple it is....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  2. Can't get loop to work or validation
    By eminem3150 in forum C++ Programming
    Replies: 11
    Last Post: 01-15-2008, 05:21 AM
  3. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  4. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

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