Thread: my comparison isn't working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    26

    my comparison isn't working

    ok i'm just starting C++ and i did a little program to get if statements down but when i run it i get an error that says "ISO C++ forbids comparison between pointer and integer" and highlights this line:
    Code:
    if (age >= 18 && localQuestion == "yes") {
    here is my entire code:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int age;
        char localQuestion;
        
        cout << "This program determines if you are eligeble to vote\n";
        cout << "How old are you? ";
        cin >> age;
        cin.ignore();
        cout << "Do you live in the U.S? ";
        cin >> localQuestion;
        cin.ignore();
        
        if (age >= 18 && localQuestion == "yes") {
                cout << "You can vote\n";
        }
        else {
             cout << "Sorry you can not vote\n";
        }
        cin.get();
    }
    Last edited by Rubiks14; 10-02-2005 at 07:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM