first I want to say, I'm pretty new to C. I have a problem with the strpbrk function.
My function gets a string. If this string contains a "¼", it should do something, if it contains a "¾" it should do something else.
static char* format_date_string3(char *string) {
printf("Found: %s\n", strpbrk(string, "¼"));
if (strpbrk(string, "¼") != NULL) {
//do something
} else if (strpbrk(string, "¾") != NULL) {
//do something else
}
}
I added the prinft for debugging purposes.
The Problem is that the output is "Found: ¼" if the string was "¼" and "Found: ¾" if the string was "¾". But for "¾" I expected the output to be NULL since the searched pattern isn't in the string. Why is this not the case? How can I change it?
Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire