Find the first character in one string that is in another.
Compatibility:This function is compatible with the following targets:
|
|
#include <string.h>
size_t strcspn(const char *s1, const char *s2);Parameters:
Parameters for this facility are:
strcspn() returns the index of the first character in s1 that matches a character in s2.
#include <string.h>
#include <stdio.h>
int main(void)
{
static char s1[] = "chocolate *cinnamon* 2 ginger";
static char s2[] = "1234*";
int i;
printf(" s1 = %s\n s2 = %s\n", s1, s2);
i = strcspn(s1, s2);
printf("Index returned by strcspn %d\n", i);
printf("Indexed character = %c\n", s1[i]);
return 0;
}
Output:
s1 = chocolate *cinnamon* 2 ginger
s2 = 1234*
Indexed character = *
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000