ISO C++ forbids comparison between pointer and integer

Discussion in 'C Programming' started by BarryKamp, Apr 25, 2007.

  1. BarryKamp

    BarryKamp

    Joined:
    Apr 25, 2007
    Messages:
    1
    Hi, Im a beginner at C, i just need some help getting something sorted where i can display information. I can add more to it for what i want to do, i just wanted to know why the error "ISO C++ forbids comparison between pointer and integer" comes for all the lines of "if ( fuel == "Petrol" ) {". Thanks for the help.

    #include <stdio.h>
    #include <stdlib.h>

    void Petrol();
    void Oil();
    void Coal();
    void Wood();
    void Electricity();
    void Naturalgas();


    int main(void)

    {
    int fuel;

    printf("Please input your fuel or activity: ");
    scanf ( "%g", &fuel );

    if ( fuel == "Petrol" ) {
    printf("you are using petrol\n");
    }
    else if ( fuel == "Oil" ) {
    printf("you are using oil\n");
    }
    else if ( fuel == "Coal" ) {
    printf("you are using coal\n");
    }
    else if ( fuel == "Wood" ) {
    printf("you are using wood\n");
    }
    else if ( fuel == "Electricity" ) {
    printf("you are using Electricity\n");
    }
    else if ( fuel == "Natural Gas" ) {
    printf("you are using Natural Gas\n");
    }
    else {
    printf("you are using Air travel\n");
    }

    getchar();
    return 0;

    }
    BarryKamp, Apr 25, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ken
    Replies:
    3
    Views:
    2,500
    Rolf Magnus
    Nov 8, 2003
  2. Henrik S. Hansen
    Replies:
    2
    Views:
    51,471
    Alf P. Steinbach
    May 2, 2004
  3. danny van elsen
    Replies:
    6
    Views:
    3,710
    Pete Becker
    May 7, 2005
  4. Penn
    Replies:
    4
    Views:
    1,379
    =?ISO-8859-1?Q?Sch=FCle_Daniel?=
    Jan 9, 2006
  5. Ravi
    Replies:
    7
    Views:
    1,041
    bodenstorfer
    Jul 30, 2011
Loading...

Share This Page