Compile problems

This is a discussion on Compile problems within the C++ Programming forums, part of the General Programming Boards category; I'm using Dev-C++, when I compile I get these errors: [Warning] In function: ISO C++ ISO C++ It says the ...

  1. #1
    Banned
    Join Date
    May 2004
    Posts
    55

    Compile problems

    I'm using Dev-C++, when I compile I get these errors:

    [Warning] In function:
    ISO C++
    ISO C++

    It says the wrong code are
    Code:
    if(choice == 'R' || choice == 'r')
    What's wrong? ><

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Nothing that I can see in that line of code, but sometimes the line number it gives you in the error message is only the line number on which it noticed there was a problem. It's not necesarily where you made the mistake. Perhaps post some more of your code?

  3. #3
    Banned
    Join Date
    May 2004
    Posts
    55
    Oks.......I've begun to make a text game, here's the code
    Code:
    #include <iostream.h>
    #include <windows.h>
    #include <string.h>
    
    void menu ()
    {
        cout << "\n\n--Menu--";
        cout << "\n[A]ttack" << endl;
        cout << "[S]pell" << endl;
        cout << "[T]alk" << endl;
        cout << "[R]eturn to village" << endl;
        cin.getline(choice, 5);
        if(choice == 'r' || choice == 'R')
        {
            if(pos==1)
            {
                cout << "You are already in town idiot.";
            }
        }
    }
    int main ()
    {
        /*  Variables    */
        char pname[80];    
        int pos = 1;
        char choice[5];
        char gname[] = "Unknown Adventures!!"; /* better name later :-)*/
        char pclass[50];
        int exp;
        int gold;
        
        /*    Begin    */
        
        cout << "Whats your name, hero?" << endl;
        cin.getline(pname, 80);
        cout << "Hello " << pname << ", and welcome to " << gname;
        Sleep(1500);
        cout << "\nWhat do you want to be?" << endl;
        cout << "Elf, Warrior, Valkyrie, Mage\n";
        cin.getline(pclass, 50);
        cout << "\n\nHello stranger.";
        cout << "\nOur forest is filled with evil monsters";
        cout << "\nKill them and I will bring you a reward.";
        menu ();
        Sleep(20000);
    }
    [Warning] In function:
    ISO C++
    ISO C++


    Thanks
    Last edited by Noxir; 08-17-2004 at 08:19 AM.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,787
    The variable choice has not been defined in menu(), and looks more like a string than a character.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    You've defined choice as an array of chars, and you're testing it as a single char. If you want to test the first char from choice you'd need to call it choice[0]. If you wanted to work with string, then you'd need to implement the special functions.

    Also (and this is a comparitively minor problem) I'm not sure if choice is global - but I can never remember all the rules about that. If I want something global I make it as global as I can get it.

  6. #6
    Banned
    Join Date
    May 2004
    Posts
    55
    Edited:
    cin.getline (choice, 0);
    void menu (char choice[0])
    char choice[0];

    Done as you guys said, here's the..

    Errors:
    ISO C++
    ISO C++
    `pos'
    (Each
    [Warning] In function:
    too few
    at this

    More errors? >_< I maybe wrote wrong, could anyone explain??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC++ 2005 Beta Compile problems
    By mrowlings in forum C++ Programming
    Replies: 5
    Last Post: 03-28-2005, 03:02 PM
  2. Compatibility Problems with Dev-C++
    By Razorblade Kiss in forum Tech Board
    Replies: 3
    Last Post: 12-18-2004, 03:15 PM
  3. Linux To FreeBSD Porting Compile Problems
    By DeepBlackMagic in forum Linux Programming
    Replies: 4
    Last Post: 03-17-2004, 07:17 AM
  4. problems with gtk+, and xlib
    By Ian in forum Linux Programming
    Replies: 3
    Last Post: 12-02-2001, 05:43 AM
  5. Compile Problems
    By Eber Kain in forum C++ Programming
    Replies: 1
    Last Post: 08-26-2001, 01:50 PM

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