Share via


_memicmp, _memicmp_l

Membandingkan karakter dalam dua buffer (tidak peka huruf besar/kecil).

Sintaks

int _memicmp(
   const void *buffer1,
   const void *buffer2,
   size_t count
);
int _memicmp_l(
   const void *buffer1,
   const void *buffer2,
   size_t count,
   _locale_t locale
);

Parameter

buffer1
Buffer pertama.

buffer2
Buffer kedua.

count
Jumlah karakter.

locale
Lokal untuk digunakan.

Nilai hasil

Nilai pengembalian menunjukkan hubungan antara buffer.

Nilai hasil Hubungan byte hitungan pertama buf1 dan buf2
< 0 buffer1 kurang dari buffer2.
0 buffer1 identik dengan buffer2.
> 0 buffer1 lebih besar dari buffer2.
_NLSCMPERROR Terjadi kesalahan.

Keterangan

Fungsi ini _memicmp membandingkan karakter pertama count dari dua buffer buffer1 dan buffer2 byte byte. Perbandingannya tidak peka huruf besar/kecil.

Jika atau buffer1buffer2 adalah penunjuk null, fungsi ini memanggil handler parameter yang tidak valid, seperti yang dijelaskan dalam Validasi parameter. Jika eksekusi diizinkan untuk melanjutkan, fungsi mengembalikan _NLSCMPERROR dan mengatur errno ke EINVAL.

_memicmp menggunakan lokal saat ini untuk perilaku dependen lokal; _memicmp_l identik kecuali menggunakan lokal yang diteruskan sebagai gantinya. Untuk informasi selengkapnya, lihat Lokal.

Secara default, status global fungsi ini dicakup ke aplikasi. Untuk mengubah perilaku ini, lihat Status global di CRT.

Persyaratan

Rutin Header yang diperlukan
_memicmp <memory.h> atau <string.h>
_memicmp_l <memory.h> atau <string.h>

Untuk informasi kompatibilitas selengkapnya, lihat Kompatibilitas.

Contoh

// crt_memicmp.c
// This program uses _memicmp to compare
// the first 29 letters of the strings named first and
// second without regard to the case of the letters.

#include <memory.h>
#include <stdio.h>
#include <string.h>

int main( void )
{
   int result;
   char first[] = "Those Who Will Not Learn from History";
   char second[] = "THOSE WHO WILL NOT LEARN FROM their mistakes";
   // Note that the 29th character is right here ^

   printf( "Compare '%.29s' to '%.29s'\n", first, second );
   result = _memicmp( first, second, 29 );
   if( result < 0 )
      printf( "First is less than second.\n" );
   else if( result == 0 )
      printf( "First is equal to second.\n" );
   else if( result > 0 )
      printf( "First is greater than second.\n" );
}
Compare 'Those Who Will Not Learn from' to 'THOSE WHO WILL NOT LEARN FROM'
First is equal to second.

Baca juga

Manipulasi buffer
_memccpy
memchr, wmemchr
memcmp, wmemcmp
memcpy, wmemcpy
memset, wmemset
_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l