Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are a number of standard functions that can achieve this, namely in string.h. Performance is a question of course.


Which functions in particular?


    strchr(str, 0) == NULL
    memchr(str, 0, len) == NULL


Those find the first zero -- not the number of contiguous zeros.


Oops, you're right. I was going to reach for `strcspn` but then realized it doesn't work for null bytes.

Huh. OP is right, there is no good function for this in the standard library.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: