在C语言中,memcmp和memicmp函数之间的区别是什么?

在c语言中,memcmp和memicmp函数之间的区别是什么?

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

Program

The following program shows the usage of memcmp() and memicmp() functions.

#include#includemain(){   char st1[]="This is C Programming language";   char st2[]="this is c programming";   int result;   result=memcmp(st1,st2,strlen(st2));   printf("

1. result after comparing buffer using memcmp");   check(result);   result=memicmp(st1,st2,strlen(st2));   printf("

2. result after comparing buffer using memicmp");   check(result);}check(int x){   if(x==0)      printf(" buffer st1 and st2 hold same data

");   if(x>0)      printf("buffer st1 is bigger than buffer st2

");   if(x

");}

登录后复制

输出

你将看到以下输出 −

1. result after comparing buffer using memcmp buffer st1 is less than buffer st22. result after comparing buffer using memicmp buffer st1 and st2 hold same data

登录后复制

以上就是在C语言中,memcmp和memicmp函数之间的区别是什么?的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2582145.html

(0)
上一篇 2025年3月6日 14:09:19
下一篇 2025年2月24日 10:41:36

AD推荐 黄金广告位招租... 更多推荐

发表回复

登录后才能评论