startswith.h 357 B

12345678910111213141516
  1. /// @file
  2. /// @ingroup cgraph_utils
  3. #pragma once
  4. #include <assert.h>
  5. #include <stdbool.h>
  6. #include <stddef.h>
  7. #include <string.h>
  8. /// does the string \p s begin with the string \p prefix?
  9. static inline bool startswith(const char *s, const char *prefix) {
  10. assert(s != NULL);
  11. assert(prefix != NULL);
  12. return strncmp(s, prefix, strlen(prefix)) == 0;
  13. }