Compare two strings: how to use strcmp
#include <stdio.h>
#include <string.h>
int main ()
{
char szKey[] = "Apple";
char szInput[80];
do {
printf ("Which is my favourite computer? ");
gets (szInput);
} while (strcmp (szKey,szInput) != 0);
printf ("Correct answer!\n");
return 0;
}
Related examples in the same category