#include <stdio.h>
#include <string.h>
#define LINELEN 256
void search_string(const char* filename, const char* needle) {
char line[LINELEN] = "";
size_t needlelen = strlen(needle);
FILE* fp = fopen(filename, "r");
if (fp == NULL) {
perror("Error opening file");
return;
}
else {
while (!feof(fp)) {
if (fgets(line, LINELEN, fp)) {
// char *strstr(const char *haystack, const char *needle)
if (strstr(line, needle)) {
puts(line);
}
}
}
}
fclose(fp);
}
int main() {
char filename[] = "d://abc.php";
char tofind[] = "str_repeat";
search_string(filename, tofind);
return 0;
}
/*
run:
echo str_repeat("\t", min(0, $post)).str_replace('\', '/', $value)."\n";
echo str_repeat("\t", max(0, $comment)).$html."\n";
*/