Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : strcspn

size_tstrcspn(const char * str1,const char * str2) ;

Return Type : size_t

Platform-specific unsigned type for array indices and memory sizes.
Read about return values of strcspn function .

1st Parameter Type : const char *

Pointer to read-only string

1st Parameter

Pointer to the null-terminated string to be scanned.

2nd Parameter Type : const char *

Pointer to read-only string

2nd Parameter

Pointer to the null-terminated string containing characters to match against `str1`.

Read more about parameters of strcspn in parameters section
The strcspnfunction in C language Scans the first string for the first occurrence of any of the characters in the second string.
The strcspn function calculates the length of the initial segment of str1 which consists entirely of characters not in str2. In other words, it returns the index of the first occurrence in str1 of any of the characters in str2, or the length of str1 if none of the characters in str2 are found in str1.
The strcspnfunction takes 2 parameters:
  • const char * `str1`: Pointer to the null-terminated string to be scanned.
  • const char * `str2`: Pointer to the null-terminated string containing characters to match against `str1`.
Calculates the length of the initial segment of `str1` that consists entirely of characters not found in `str2`. Returns the number of characters in this segment as a `size_t`.
The strcspn function return value :
  • Returns the number of characters in the initial segment of str1 which are not in str2

Output

This example demonstrates basic usage of strcspn to find the first occurrence of any punctuation mark in a string.