Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > ISO C++ forbids comparison between pointer and integer

Reply
Thread Tools

ISO C++ forbids comparison between pointer and integer

 
 
BarryKamp BarryKamp is offline
Junior Member
Join Date: Apr 2007
Posts: 1
 
      04-25-2007
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;

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISO C++ forbids "set" and "get" as method names? Ravi C++ 7 07-30-2011 01:00 PM
ISO C++ forbids declaration of `cout' with no type. Penn C++ 4 01-09-2006 11:47 PM
error: ISO C++ forbids cast to non-reference type used as lvalue danny van elsen C++ 6 05-07-2005 05:56 PM
ISO C++ forbids declaration of "tst" with no type Henrik S. Hansen C++ 2 05-02-2004 08:38 PM
ISO C++ forbids casting between pointer-to-function and pointer-to-object ken C++ 3 11-08-2003 12:08 PM



Advertisments