Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : memcmp

intmemcmp(const void * ptr1,const void * ptr2,size_t num) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of memcmp function .

1st Parameter Type : const void *

A pointer to a constant memory location of unspecified type. The pointed-to data cannot be modified through this pointer.

1st Parameter

Pointer to the first block of memory to compare.

2nd Parameter Type : const void *

A pointer to a constant memory location of unspecified type. The pointed-to data cannot be modified through this pointer.

2nd Parameter

Pointer to the second block of memory to compare.

3rd Parameter Type : size_t

Platform-specific unsigned type for array indices and memory sizes.

3rd Parameter

The number of bytes to compare between the two memory blocks.

Read more about parameters of memcmp in parameters section
The memcmpfunction in C language Compares two blocks of memory.
The memcmp function compares the first n bytes of the object pointed to by s1 to the first n bytes of the object pointed to by s2. The comparison is done lexicographically, treating the bytes as unsigned char values.
The memcmpfunction takes 3 parameters:
  • const void * `ptr1`: Pointer to the first block of memory to compare.
  • const void * `ptr2`: Pointer to the second block of memory to compare.
  • size_t `num`: The number of bytes to compare between the two memory blocks.
Compares the first `num` bytes of the memory blocks pointed to by `ptr1` and `ptr2`. Returns a negative value if the first differing byte in `ptr1` is less than the corresponding byte in `ptr2`, zero if the blocks are equal, or a positive value if the first differing byte in `ptr1` is greater than the corresponding byte in `ptr2`.
The memcmp function return value :
  • Returns an integer less than, equal to, or greater than zero if the first n bytes of s1 is found, respectively, to be less than, to match, or be greater than the first n bytes of s2

Output

This example demonstrates basic usage of memcmp to compare two strings.