fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char buf[] = {90, 12, 89, 0, 11};
  6. size_t idx = memchr(buf, 11, sizeof(buf)) - (void*)buf;
  7. printf("Index of 11 is %lu\n", idx);
  8. idx = memchr(buf, 0, sizeof(buf)) - (void*)buf;
  9. printf("Index of 0 is %lu\n", idx);
  10. }
  11.  
Success #stdin #stdout 0s 5536KB
stdin
Standard input is empty
stdout
Index of 11 is 4
Index of 0 is 3