0

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

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by rxlim
1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.