Borland C++ reference

strspn, _fstrspn

raw OCR

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

Defined in header <string.h>

Syntax

#include <string.h>
Near version: sizet strspn(const char *sl, const char *s2);
Far version: size_t far _fstrspn(const char far *sl,const char far *s2)

Portability

DOSUNIXWindowsANSI CC++ only
Near version ■■■■
■■

Remarks

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

Return value

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

Example

#include <stdio.h>
#include <string.h>
#include <alloc.h>

int main(void)
{
   char *stringl = "1234567890", *string2 =  "123DC8";
   int length;
   length = strspn(stringl, string2);
   printf("Character where strings differ is at position  %d\n", length);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.