C strspn() Function
You are Here:
C strspn()
The strspn()
function finds up to what length two strings are identical.
Example
C Compiler
#include <stdio.h>
#include <string.h>
int main()
{
char str1[] = "wikimass is awesome";
char str2[] = "wikipedia is great";
long len = strspn(str1, str2);
printf("Length of initial segment matching: %ld", len);
return 0;
}
Output
Length of initial segment matching: 4
Syntax
size_t strspn(const char *str1, const char *str2)
Parameter Values
Value | Type | Explanation |
---|---|---|
str1 | Required | Specifies the string 1 |
str2 | Required | Specifies the string 2 |
Return Value
Value | Explanation |
---|---|
Number | Returns the position of the string from where the source array does not matches with the target one. |
Reminder
Hi Developers, we almost covered 98% of String functions and Interview Question on C with examples for quick and easy learning.
We are working to cover every Single Concept in C.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.