Simply use the same logic for the program, that you would use for solving this, with paper and pencil.
This is the idea - this is NOT ready to run code.
Code:
len = strlen(string);
for(i=0,j=0;i<len;i++) {
if(string[i] == code[j]) { //found the first letter of the code
j=i;
while(a[j] == code[j]) { //while the string has matching letters
++j;
//print it or whatever you want to process matches
}
//does j match the length of the code string?
//if so, you have a full match, else a partial match
}
}
Study your problem, and you'll get it. You'll want to include string.h for most work with strings, of course.