[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


strspn

Find the first character in one string that is not in another.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <string.h>
size_t strspn(const char *s1, const char *s2);
Parameters:

Parameters for this facility are:

s1  
const char *  
The string to count  
s2  
const char *  
A list of characters to look for  

Remarks:

The strspn() function finds the first character in the null terminated character string s1 that is not in the null terminated string s2. The function starts examining characters at the beginning of s1 and continues searching until a character in s1 does not match any character in s2.

Both s1 and s2 must point to null terminated character arrays.

Return:

strspn() returns the index of the first character in s1 that does not match a character in s2.

See Also:

"strpbrk"

"strcspn"

Example of strspn() usage.:
#include <string.h>
#include <stdio.h>

int main(void)
{
	static char s1[] = "create *build* construct";
	static char s2[] = "create *";

	printf(" s1 = %s\n s2 = %s\n", s1, s2);
	printf(" %d\n", strspn(s1, s2));

	return 0;
}

Output:
s1 = create *build* construct
 s2 = create *
 8


[ 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