Keil Logo


#include <string.h>

int strcspn (
  const char *src,    /* source string */
  const char *set);   /* characters to find */

The strcspn function searches the src string for any of the characters in the set string.

Return Value

The strcspn function returns the index of the first character located in src that matches a character in set. If the first character in src matches a character in set, a value of 0 is returned. If there are no matching characters in src, the length of the src is returned.

See Also

strchr, strpbrk, strpos, strrchr, strrpbrk, strrpos, strspn

#include <string.h>
#include <stdio.h> /* for printf */

void tst_strcspn (void) {
  char buf [] = "13254.7980";
  int i;

  i = strcspn (buf, ".,");

  if (buf [i] != '\0')
    printf ("%c was found in %s\n",
            (char) buf [i],
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.