code-tutorial.com

The best resources for developers

String.indexOf in C is the most important function. It is useful for any user of C with little knowledge about C syntax.

/* strcspn example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] = "fcba73";
  char keys[] = "1234567890";
  int i;
  i = strcspn (str,keys);
  printf ("The first number in str is at position %d.
",i+1);
  return 0;
}

Tags: c string

Source: By Ryan Ahearn as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5


Related code-snippets: