Can someone help me with this search pattern so that it locates
the pattern regardless of position in the line buffer?
Here's what I have for code:
sprintf((char *)patternToSearch,"%s", (char *)my_search_string);
while (fgets(buffer, sizeof(buffer), fp)) {
sprintf((char *)patternToSearch,"%s", (char *)my_search_string);
if (strncmp((char *)patternToSearch,
buffer, strlen((char
*)patternToSearch))) {
/* are we writing to a temp
file? */
if (file_cmd == 4) {
fputs(buffer, temp);
}
} else {
matched = true;
/* are we writing to a temp file? if yes then comment
out the matched line */
if (file_cmd == 4) {
fprintf(temp, "#");
fputs(buffer, temp);
}
}
}
if (is_verbose) {
if (matched) {
printf("Found match for :
%s\n", patternToSearch);
} else {
printf("No match for : %s\n", patternToSearch);
}
}