
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strspn() in C
The function strspn() is used to calculate the length of substring of first string which is present in second string. It returns the length of that substring.
Here is the syntax of strspn() in C language,
size_t strspn(const char *string1, const char *string2);
Here is an example of strspn() in C language,
Example
#include <stdio.h> #include<string.h> int main() { const char s1[] = "Helloworld!"; const char s2[] = "Hello"; int length = strspn(s1, s2); printf("The length of string : %d", length); return 0; }
Output
The length of string : 5
Advertisements