2018-05-29 18:29:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static const char fox[] = "The quick brown fox jumped over the lazy dogs.";
|
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
int fails = 0;
|
|
|
|
|
|
|
|
int main (void)
|
2018-05-29 18:29:50 +00:00
|
|
|
{
|
|
|
|
printf ("Testing strpbrk():\n");
|
|
|
|
if (strpbrk (fox, "qwerty") != &fox[2]) {
|
|
|
|
printf ("\nThe first 'e' wasn't found.\n");
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|
|
|
|
if (strpbrk (fox, "QWERTY") != &fox[0]) {
|
|
|
|
printf ("The 'T' wasn't found.\n");
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|
|
|
|
if (strpbrk (fox, "asdfg") != &fox[16]) {
|
|
|
|
printf ("The 'f' wasn't found.\n");
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|
|
|
|
if (strpbrk (fox, "nxv,zmb") != &fox[10]) {
|
|
|
|
printf ("The 'b' wasn't found.\n");
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|
|
|
|
if (strpbrk (fox, "!@#$%^&*()-+=[];:',/?<>.") != &fox[45]) {
|
|
|
|
printf ("The '.' wasn't found.\n");
|
2020-07-13 19:26:07 +00:00
|
|
|
fails++;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 19:26:07 +00:00
|
|
|
printf ("\nFinished. fails = %d\n", fails);
|
|
|
|
return fails;
|
2018-05-29 18:29:50 +00:00
|
|
|
}
|