
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
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
- Related Articles
- What is strspn() Function in C language?
- strspn() function in PHP
- isless() in C/C++
- islessgreater() in C/C++
- isgreater() in C/C++
- modf() in C/C++
- isblank() in C/C++
- islessequal() in C/C++
- strxfrm() in C/C++
- Comments in C/C++
- isgreaterequal() in C/C++
- ungetc() in C/C++
- (limits.h) in C/C++
- Pointers in C/C++
- fseek() in C/C++

Advertisements