CKTIS / C
strpbrk — first character from a set
strpbrk finds the first character in a string that belongs to the character set supplied by another string. It returns a pointer to the match or NULL.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <string.h>
QChar *strpbrk(QChar *s1, const char *s2);strpbrk from <string.h> searches s1, treating s2 as a character set, not a substring. Position in s1 wins, not order in s2.
In the C23 syntax, QChar is standard notation, not a type to declare: char * produces char *, and const char * produces const char *.
Both arguments must point to valid \0-terminated strings; do not pass NULL. Check the result before dereferencing. The function leaves data unchanged.
The terminating \0 is not a search character; empty s1 or s2 yields NULL. Issue 1019 clarifies this imprecision in the C23 wording.
Examples
#include <stdio.h>
#include <string.h>
int main(void)
{
const char text[] = "red,green;blue";
const char *p = strpbrk(text, ";,");
if (p != NULL) {
printf("%c at %td\n", *p, p - text);
} else {
puts("not found");
}
return 0;
}
Result
, at 3
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.