Memcmp() and memicmp() compares first n bytes of two blocks of memory.
memcmp() performs comparison as unsigned characters.
memicmp() performs comparison as characters but, ignore upper case or lower case letters.
Both functions return an integer value.
立即学习“C语言免费学习笔记(深入)”;
Two memory buffers are equal (returns 0).
First buffer is greater than second (returns >0).
First buffer is less than second(returns
The following program shows the usage of memcmp() and memicmp() functions.
#include<conio.h> #include<mem.h> main(){ char st1[]="This is C Programming language"; char st2[]="this is c programming"; int result; result=memcmp(st1,st2,strlen(st2)); printf("</p><p>1. result after comparing buffer using memcmp"); check(result); result=memicmp(st1,st2,strlen(st2)); printf("</p><p>2. result after comparing buffer using memicmp"); check(result); } check(int x){ if(x==0) printf(" buffer st1 and st2 hold same data</p><p>"); if(x>0) printf("buffer st1 is bigger than buffer st2</p><p>"); if(x<0) printf(“ buffer st1 is less than buffer st2</p><p>"); }
你将看到以下输出 −
1. result after comparing buffer using memcmp buffer st1 is less than buffer st2 2. result after comparing buffer using memicmp buffer st1 and st2 hold same data
以上就是在C语言中,memcmp和memicmp函数之间的区别是什么?的详细内容,更多请关注php中文网其它相关文章!
C语言怎么学习?C语言怎么入门?C语言在哪学?C语言怎么学才快?不用担心,这里为大家提供了C语言速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号