codescracker


c

C strspn()



« Previous Chapter Next Function »


strspn()

The strspn() function returns the length of the initial substring of the string pointed to by str1 that is made up of only those characters contained in the string pointed to by str2. Stated differently, strspn() returns the index of the first character in the string pointed to by str1 that does not match any of the characters in the string pointed to by str2.

strspn() Syntax

Following is the syntax of the strspn() function :

#include<string.h>
size_t strspn(const char *str1, const char *str2);

strspn() Example

Following program prints 8 :

#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int len;
	len = strspn("this is a test", "siht ");
	printf("%d", len);
	getch();
}

« Previous Chapter Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test