hi all,
I am trying to create a pointer to a member of a struct and then do a boolean comparison to see if there is currently anything in that member.

here is what I have so far:

card* openPtr = opencells;
char* rankPtr;

rankPtr = (*openPtr).rank;  

cout<<"          Free Cells           "<<endl;

cout<<"1         2         3         4" << endl;

cout << endl;

for (int i=0; i<NUM_FREE_CELLS; i++)

         {      
    if (*rankPtr !='\0')

    {

        print_card(rankPtr);
        {

        if (*rankPtr=='0')

            cout<<"  ";


        else
 if (*rankPtr > 13)
            cout<<"   ";

        } openPtr++;        
    }

    else

        cout<<"      ";

cout<<endl;

         }

the struct is type card, and opencells is an array of type card that has been passed to the function. I'm getting an error when attempting to compare *rankPtr to a value.

Thanks for any insight

You should be able to compare *rankPtr to a character value, maybe not to an integer value depending on your compiler's error/warning settings. What is the error? It makes no sense to compare *rankPtr to both characters and integers.. Also, the loop looks strange, you are increasing the openPtr pointer without using it in the loop? There is no point in checking the value of *rankPtr in the loop since it will never change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.