RAD Studio
ContentsIndex
PreviousUpNext
strcspn, _mbscspn, wcscspn

Header File 

string.h, wchar.h, mbstring.h 

Category 

Memory and String Manipulation Routines 

Prototype 

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

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

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

Description 

Scans a string for the initial segment not containing any subset of a given set of characters. 

The strcspn functions search s1 until any one of the characters contained in s2 is found. The number of characters which were read in s1 is the return value. The string termination character is not counted. Neither string is altered during the search. 

Return Value 

strcspn returns the length of the initial segment of string s1 that consists entirely of characters not from string s2. 

Example  

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

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strcspn 
_mbscspn 
 
 
 
wcscspn 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!