I need to reproduce behavior of strnstr function. I want to test strnstr but can't compile program, its written "implicit declaration of function strnstr [-Wimplicit-function-declaration]" and "undefined reference to strnstr". I included header <string.h>.
I know that strnstr() isn't in standard library and the problem is probably connected with compiler, but how to fix it to work with strnstr()?
Compiler version: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
There's no function named strnstr in standard C or POSIX. It's not in glibc/Linux either.
It appears to be FreeBSD function.
I know that strnstr() isn't in standard library and the problem is probably connected with compiler, but how to fix it to work with strnstr()?
Not sure why you think it's a compiler issue (unless you think it's a compiler intrinsic). If it's not provided by your C library, it's just not available.
So if it's not available on your system (probably you are not using a BSD system) then you can implement it. You can look at an existing implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With