RAD Studio
ContentsIndex
PreviousUpNext
strspn, _mbsspn, wcsspn

Header File 

string.h, mbstring.h 

Category 

Memory and String Manipulation Routines 

Prototype 

size_t strspn(const char *s1, const char *s2); 

size_t wcsspn(const wchar_t *s1, const wchar_t *s2); 

size_t _mbsspn(const unsigned char *s1, const unsigned char *s2); 

Description 

Scans a string for the first segment that is a subset of a given set of characters. 

strspn finds the initial segment of string s1 that consists entirely of characters from string s2. 

Return Value 

strspn returns the length of the initial segment of s1 that consists entirely of characters from s2. 

Example  

#include <stdio.h>
#include <string.h>
#include <alloc.h>
int main(void)
{
   char *string1 = "1234567890";
   char *string2 = "123DC8";
   int length;
   length = strspn(string1, string2);
   printf("Character where strings differ is at position %d\n", length);
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strspn 
_mbsspn 
 
 
 
wcsspn 
 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!