ISO C++ forbids comparison between pointer and integer

Joined
Apr 25, 2007
Messages
1
Reaction score
0
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;

}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,851
Latest member
CliftonCor

Latest Threads

Top