Q:

search and compare a string with an array of strings

This is the code I have
const char *s[5];={"abcd","efgh","ijkl","mnop","qrst"};
char a[4];
while (1)
      {
      scanf("%4s",&a);

      //compare a with s array

      if(/*a exists in s*/)
      printf("it is ok");

      if(/*a does not exist in s*/)
      printf("it is not ok");
}

For example when I type "dcba" I want to see "it is not ok". When I type "efgh" I want to see "it is ok".

A:

First declare your arrays a as  
char a[5];

use fgets to input string (do not use scanf), then use strcmp or strncmp function to compare the two string/(literals).  

