Results 1 to 5 of 5

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

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

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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") {
    ...
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

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

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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.

Similar Threads

  1. Replies: 2
    Last Post: 24-01-2012, 01:06 PM
  2. Changing Stylus pointer to normal Pointer in Tablet PC
    By Kelley in forum Portable Devices
    Replies: 3
    Last Post: 21-06-2011, 07:22 PM
  3. PagePlus Cellular forbids Verizon Wireless Smartphones
    By Laquan in forum Portable Devices
    Replies: 4
    Last Post: 24-11-2010, 03:22 PM
  4. Null pointer error in java
    By Elizabeth Allen in forum Software Development
    Replies: 5
    Last Post: 19-03-2010, 02:26 PM
  5. Differentiation between void pointer and null pointer
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 18-01-2010, 12:11 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,580,466.44651 seconds with 17 queries