"comparison between integer and pointer" is usually caused by:
Code:
char buffer[X];
if (buffer == 'A') ...
Now, 'A' is the same as 65 [assuming we are using the ASCII/ANSI character set - other character sets use different encodings, but the result is the same], and buffer is the address (in other words a pointer to) the first character in buffer - so you are checking if the memory used for buffer is at location 65 in memory - which the compiler finds to be an unlikely thing to do and gives a warning. It is perfectly LEGAL to make such a comparison, and it may even be the right thing at times - but most fo the time, it's completely wrong, and if your code looks something like the above, then you are definitely not comparing what you think you are comparing.
Perhaps you want to compare the first character of the buffer, by comparing buffer[0] with the relevant posisble answers?
Also, if this happens to be inside
Code:
void askUserQuestion( int guessNumber, char* question, int* animalData )
, then the code will crash if someone happens to put a book on the enter key - because EVENTUALLY you will run out of stack. I also don't think it's actually the right thing to do regardless of whether it tolerates "book on enter key" accidents, because you have no way of skipping back to where you came from within the askUserQuestion() and the one that you started from - so if the user answers wrong three times in a row, you will be three levels into the askUserQuestion() function, but when you go back, you will go back to the previous level and perform whatever operations it does after returning from the previous call.
By the way, if you still have this:
Code:
if ( strncmp( buffer, YES_KEY, 1 ) == 0 )
{
/* If the user answer is yes, then remove animals do not match */
if ( animalData[ index ] != 1 )
animals_list[ index ] = NULL;
}
else
{
/* If the user answer is no, then remove animals which match */
if ( animalData[ index ] == 1 )
animals_list[ index ] = NULL;
}
in your askUserQuestion(), then you could simplify it:
Code:
int selectionCriteria;
if ( strncmp( buffer, YES_KEY, 1 ) == 0 )
{
selectionCriteria = 0;
}
else
{
selectionCriteria = 1;
}
if ( animalData[ index ] == selectionCriteria )
{
animals_list[ index ] = NULL;
}
That way, you don't repeat essentially the same test in two places.
--
Mats