A pure bytes version of strstr?

后端 未结 3 960
失恋的感觉
失恋的感觉 2021-01-17 15:08

Is there a version of strstr that works over a fixed length of memory that may include null characters?

I could phrase my question like this: strncpy is to memcpy as

3条回答
  •  有刺的猬
    2021-01-17 15:16

    Not in the standard library (which is not that large, so take a look). However writing your own is trivial, either directly byte by byte or using memchr() followed by memcmp() iteratively.

提交回复
热议问题