Hi
I have posted the code for the program. This is the code that works, but I do not understand why. In function "compare" there is condition: if(string[0] == pSuit[i]). Why it does not work if I have if(*string[0] == *pSuit[i]) (with cast)?
Code:
#include <stdio.h>
void compare(const char *pSuit[]);
int main()
{
const char *suit[4] = {"Hearts", "Diamonds", "Clubs", "Spades"};
compare(suit);
return 0;
}
void compare(const char *pSuit[])
{
int i;
const char *string[1] = {"Clubs"};
for(i = 0; i < 4; i++)
{
if(string[0] == pSuit[i])
{
printf("*pSuit == %s, i == %d\n", pSuit[i], i);
}
}
}