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;
}
#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;
}