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++
- Conditional or Ternary Operator (?:) in C/C++
- Random-Scan Display
- Raster-Scan Displays
- Difference between Optical Character Recognition (OCR) and Magnetic Ink Character Reader (MICR)
- Difference between Microeconomics and Macroeconomics
- C program to Insert an element in an Array
- Basics of management
- OpenCV | Hands on Image Brightness
- Difference between Fuzzification and Defuzzification
- Issues in Cloud Computing
- Types of Literals in C/C++ with Examples
- asctime() and asctime_s() functions in C with Examples
- time.h header file in C with Examples
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.