strcspn, _fstrcspn
raw OCR
Scans a string for the initial segment not containing any subset of a given set of characters.
Defined in header <string.h>
Syntax
#include <string.h>
Near version: size_t strcspn(const char *sl, const char *s2);
Far version: sizet far far _fstrcspn(const char far *sl, const char far*s2)
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| Near version | ■ | ■ | ■ | ■ | |
| ■ | ■ |
Return value
strcspn returns the length of the initial segment of string si that consists entirely of characters not from string s2.
See also
strctirstrrchr
Example
include <stdio.h>
#include <string.h>
#include <alloc.h>
int main(void)
{
char *stringl = "1234567890", *string2 = "747DC8";
int length;
length = strcspn(stringl, string2);
printf("Character where strings intersect 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.
Stable link: /3.1/string.h/strcspn/
· short form /3.1/strcspn/