Compare some characters of two strings: how to use strncmp
#include <stdio.h> #include <string.h> int main () { char str[][5] = { "CS115" , "CS334" , "CS445" , "CS335" , "CS889" }; int n; printf ("Looking for a class...\n"); for (n=0 ; n < 5 ; n++) if (strncmp (str[n],"CS33*",1) == 0) { printf ("found %s\n",str[n]); } return 0; }