If the question is "What's wrong with the code?"; here are a few things to start with:
printf("Matches found: %d\n", bmhSearch(needle); // Missing a final ')'.
int main(void)
{
...
return(0); // Something like this line is required for a function that returns'int'.
}
size_t bad_char_skip[UCHAR_MAX + 1]; // Requires: '#include <limits.h>
if((fopen_s(&fp, "book.txt", "r")) != NULL) {
The function 'fopen_s()' does not return a pointer. It returns an errno_t type, which is an integer value. Comparing an integer with 'NULL' is like showing up at the 'Indian war-dance' dressed as a cowboy. Perhaps the following is more appropriate:
if((fopen_s(&fp, "book.txt", "r")) != 0) {
which is equivalent to (my favorite):
if(fopen_s(&fp, "book.txt", "r")) {
printf("%d\t%d\n", hlen, nlen);
The above format string is incorrect. it should be:
printf("%zu\t%zu\n", hlen, nlen);
In a strict C sense, the following lines need attention:
bad_char_skip[needle[scan]] = last - scan;
hlen -= bad_char_skip[ptemp[last]];
ptemp += bad_char_skip[ptemp[last]];
They should be changed to the following:
bad_char_skip[(int)needle[scan]] = last - scan;
hlen -= bad_char_skip[(int)ptemp[last]];
ptemp += bad_char_skip[(int)ptemp[last]];
The variable 'ptemp' is defineded as a 'char *'. Hence; 'ptemp[n]' evaluates as a 'char' type; while an array index number must be 'int'.