Thread: Help me

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    Help me

    I need some help here, why this program is not working? What should be his correct form?

    Code:
    #include <iostream>
    using namespace std;
    struct database {
           int Telefone();
           };
           int main()
           {
               string x;
               cout<<"Testing\n";
               cin>> x;
               cin.ignore();
               if ( x = Teste ) {
                    database Teste;
                    database *ptr;
                    teste.Telefone = 33327731
                    *ptr = &database;
                    cout<< ptr->Telefone
                    cin.get();
                    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Code:
            if ( x = Teste ) {
    Use the "==" boolean operator, not the "=" assignment operator.

    what is Teste ? is it a std::string or char array that was defined somewhere else (remember, variables have to be defined before they can be used)? Maybe you meant this
    Code:
            if ( x == "Teste" ) {
    Last edited by Ancient Dragon; 10-19-2005 at 12:14 PM.

  3. #3
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    where to begin?

    first, you are missing an } at the end.
    second, the formatting is horrible to read.
    third, you are comparing x with an undefined variable name (maybe you meant "Teste").
    fourth, you are not allocating data for ptr.
    fifth, you are assigning the value of *ptr to the address of database, (it should be *ptr = database).
    sixth, is Telefone a function or a variable? You are defining it as a func but using it as a var.

    EDIT: seveth, what AD said

Popular pages Recent additions subscribe to a feed