]> git.ozlabs.org Git - ccan/blobdiff - ccan/str/str.h
str: change example to match function being explained.
[ccan] / ccan / str / str.h
index 8cfd7f29a5626cb7ca3a3196e545f35c3a74c0be..bf858f13b69cb1f671a895450004f36a6ad361cd 100644 (file)
@@ -55,4 +55,18 @@ static inline bool strends(const char *str, const char *postfix)
 #define stringify(expr)                stringify_1(expr)
 /* Double-indirection required to stringify expansions */
 #define stringify_1(expr)      #expr
+
+/**
+ * strcount - Count number of (non-overlapping) occurrences of a substring.
+ * @haystack: a C string
+ * @needle: a substring
+ *
+ * Example:
+ *     int i;
+ *      i = strcount("aaa aaa", "a");  // i = 6;
+ *      i = strcount("aaa aaa", "ab"); // i = 0;
+ *      i = strcount("aaa aaa", "aa"); // i = 2;
+ */
+size_t strcount(const char *haystack, const char *needle);
+
 #endif /* CCAN_STR_H */