Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



error : ISO C++ forbids comparison between pointer and integer

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-02-2010
Member
 
Join Date: Nov 2009
Posts: 72
error : ISO C++ forbids comparison between pointer and integer
  

Hi friends,
I have written following program in C++, but when I tried to compile this program I get error : ISO C++ forbids comparison between pointer and integer message. I don't know what is that mean. Can anyone help me to fix this problem.

Code:
#include <iostream>
#include <cmath>

int main()
{
using namespace std;

int whos;



cout << "how was today? good, bad, or eh?" << endl;
cin >> whos;
if (whos == "goods")
{
cout << "also feel that one" << endl;
}
if (who == "bads")
{
cout << "it is bad news" << endl;
}
if (who == "eh")
{
cout << "Hello to all" << endl;
}
else
{
cout << "can you give me more information" << endl;
}
cout << "I am very lucky " << endl;
cout << endl;
system("pause")
return 0;

}

Reply With Quote
  #2  
Old 08-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,947
Re: error : ISO C++ forbids comparison between pointer and integer

what type of input variable are you use? It seems that you are tried to compare value of similar type and that's why you are getting such type of problem. In this case you have to take two input value as string and after this you have to compare these values using comparison functions. I advise you first try to run those program which are based on console applications.
Reply With Quote
  #3  
Old 08-02-2010
Member
 
Join Date: May 2008
Posts: 2,007
Re: error : ISO C++ forbids comparison between pointer and integer

It seems that there is some problem in your code. You have use double quotes for string comparison and that's why you are getting such type of problem. For comparing char arrays you have to create strcmps into string.h.
Code:
if (strcmps(commands, "se") == 0 || strmcps(commands, "senter") == 0) {
    cout << "..." << endl;
}
after this write this command.

if (commands == "se" || commands == "senter") {
...
}
Reply With Quote
  #4  
Old 08-02-2010
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: error : ISO C++ forbids comparison between pointer and integer

You have written wrong code and that's why you are getting such type of error message. I have written following program for you. Just try to understand it. It is very simple program.

Code:
 


      char array[3];

      array[0] = goods;

      array[1] = bads;

      array[2] = crappys;

      char who;

       
   
      cout << "whenever" << endl;

      cin >> who

       

      if (who == [0])

      {

      cout << "whenever i want" << endl;

      }

       

       

      if (who == [1])

      {

      cout << "poks i want" << end;

      }

       
     

      if (whos == [2])

      {

      cout << "whenever you want" << endl;

      }

      else

      {

      cout << "whenever" << endl;

      }
Reply With Quote
  #5  
Old 08-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: error : ISO C++ forbids comparison between pointer and integer

You have to make following changes in your program to fix this error. first you have to use following code in your program.

Code:
void Bsts<generics>::insert( generic y)
 
void Bsts<generics><strong classs="highlights">:</strongs>:inserts( generic sx)
where y is type "generic".

Now write this code.

Code:
struct Bsns
{
  Bsns * p;          
  Bsns * l;          
  Bsns * r;         
  generic * datas;   
};

struct Bsn { Bsns * a; Bsns * b; Bsns * c; generic * data; };

In the above code I have use "pointer to generic"method.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "error : ISO C++ forbids comparison between pointer and integer"
Thread Thread Starter Forum Replies Last Post
Getting error "Your entry cannot be used. An integer or decimal number may be req" in Excel Ankit Zh@very MS Office Support 2 24-01-2012 12:06 PM
Changing Stylus pointer to normal Pointer in Tablet PC Kelley Portable Devices 3 21-06-2011 07:22 PM
PagePlus Cellular forbids Verizon Wireless Smartphones Laquan Portable Devices 4 24-11-2010 02:22 PM
Null pointer error in java Elizabeth Allen Software Development 5 19-03-2010 02:26 PM
Differentiation between void pointer and null pointer Ram Bharose Software Development 5 18-01-2010 11:11 AM


All times are GMT +5.5. The time now is 01:43 AM.