The problem is that if search_string()
doesn't find the string, it returns NULL
. You then pass that NULL
to printf()
, which crashes.
In main()
, you need something like:
if (tmp2)
printf("%s\n", tmp2);
Also, the tmp2
variable should be of type char *
, not char **
. And there's no reason not to declare it local to main()
.