Most asked top Interview Questions and Answers & Online Test
Education platform for interview prep, online tests, tutorials, and live practice

Build skills with focused learning paths, mock tests, and interview-ready content.

WithoutBook brings subject-wise interview questions, online practice tests, tutorials, and comparison guides into one responsive learning workspace.

Prepare Interview

Language in C Interview Questions and Answers

Question: The functions memcmp( ) and memicmp( )

Answer: The functions memcmp( ) and memicmp( ) compares first n bytes of given two blocks of memory or strings. However, memcmp( ) performs comparison as unsigned chars whereas memicmp( ) performs comparison as chars but ignores case (i.e. upper or lower case). Both the functions return an integer value where 0 indicates that two memory buffers compared are identical. If the value returned is greater than 0 then it indicates that the first buffer is bigger than the second one. The value less than 0 indicate that the first buffer is less than the second buffer. The following code snippet demonstrates use of both

#include <stdio.h>
#include <mem.h>

main( )
{
char str1[] = "This string contains some
characters" ;
char str2[] = "this string contains" ;
int result ;

result = memcmp ( str1, str2, strlen ( str2 ) ) ;
printf ( "nResult after comapring buffer using
memcmp( )" ) ;
show ( result ) ;

result = memicmp ( str1, str2, strlen ( str2 ) ) ;
printf ( "nResult after comapring buffer using
memicmp( )" ) ;
show ( result ) ;
}

show ( int r )
{
if ( r == 0 )
printf ( "nThe buffer str1 and str2 hold
identical data" ) ;
if ( r > 0 )
printf ( "nThe buffer str1 is bigger than buffer
str2" ) ;
if ( r < 0 )
printf ( "nThe buffer str1 is less than buffer
str2" ) ;
}

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful? Yes No

Most helpful rated by users:

Copyright © 2026, WithoutBook.