Code:
int name[] = {"EDDIE","BEN","DAVE"};
U are comparing with the int array which is not right. Perhaps it should have been a 2D string. And even more the strcmp string is expecting the char * not int * or char[][].
So above code should be
Code:
char name[][20] = {"EDDIE","BEN","DAVE"};
And perhaps you now should change your code to suite he above statment
Code:
#include <stdio.h>
#include <string.h>
int main()
{
char name[][20] = {"EDDIE","BEN","DAVE"};
int i;
char guess[10];
int correct = 0;
char * p;
printf("Enter a name in uppercase: ");
while(!correct)
{
fgets(guess ,10, stdin);
p = strchr(guess, '\n');
if ( p )
*p = 0;
for(i=0;i<3;i++)
{
if(strcmp(name[i], guess)==0)
{
printf("Correct!\n");
correct = 1;
getchar();
return 0;
}
}
printf("Try again: ");
}
getchar();
return 0;
}
ssharish2005