The C library function strcspn() calculates the length of the number of characters before the 1st occurrence of character present in both the string.
strcspn(const char *str1, const char *str2) Parameters: str1 : The Target string in which search has to be made. str2 : Argument string containing characters to match in target string. Return Value: This function returns the number of characters before the 1st occurrence of character present in both the string.
The unmatched characters before first matched character : 3
Practical Application : There can be many practical application of this function, be it word games or irregularity calculator. A simple word game is demonstrated in this article.
Rules : According to this game, 2 players play and one player initially generated a string and is asked to produce a string which has as many unmatched characters. After 1 round, player producing string with maximum unmatched characters wins.
Match Drawn!! Score : 2
- strcspn() function in C/C++
- tgamma() method in C/C++ with Examples
- Modulo Operator (%) in C/C++ with Examples
- fpclassify() method in C/C++ with Examples
- Introduction of JIRA
- Signal Processing and Time Series (Data Analysis)
- getch() function in C with Examples
- Chain of Pointers in C with Examples
- Pointer Expressions in C with Examples
- Speed up Code executions with help of Pragma in C/C++
- Cryptocurrency and Cryptojacking
- Detecting top nodes on a Social Network - The VoteRank Algorithm
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.