当前位置:网站首页>Memcpy() function copies two-dimensional array & memcmp() function compares two-dimensional array
Memcpy() function copies two-dimensional array & memcmp() function compares two-dimensional array
2022-04-22 14:56:00 【YouthUpward】
ps: The header files of both functions are #include <string.h>
memcpy( ) function
memcpy( ) yes C/C++ Memory copy function used , The function prototype is void *memcpy(void *destin, void *source, unsigned n); The function copies several bytes from the starting position of the source memory address to the target memory address , namely From source source Middle copy n Bytes to target destin in .
#include <stdio.h>
#include <string.h>
int main( )
{
int src[2][3] = {
{
1,2,3},{
4,5,6}};
int des[2][3] = {
0 };
// Put two-dimensional array src Copied to the des Array
memcpy(des, src, sizeof(src));
// Print
for(int i = 0;i < 2;i++)
{
for(int j = 0;j < 3;j++)
{
printf("%d",des[i][j]);
}
printf("\n");
}
return 0;
}

memcmp( ) function
memcmp The prototype of the function is int memcmp(const void *str1, const void *str2, size_t n)); Its function is Store str1 And storage str2 Before n Compare bytes . Because it is based on memory byte comparison , Therefore, the actual data type to be compared can be integer 、 String, etc. .
#include <stdio.h>
#include <string.h>
int main( )
{
int src[2][3] = {
{
1,2,3},{
4,5,6}};
int des[2][3] = {
{
1,2,3},{
4,5,6}};
int res = memcmp(des, src, sizeof(src));
printf("%d",res);
return 0;
}
memcmp( ) The return value of the function is 0 Indicates that two arrays are the same , The return value is 1 Express des > src, The return value is -1 Express des < src

版权声明
本文为[YouthUpward]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221446360507.html
边栏推荐
- 【ORB_SLAM2源码解读】分析ORB_SLAM2 RGBD 第1帧是怎么计算位置姿态的
- Machine learning model fusion method!
- Android eye protection function, double non undergraduate byte beating Android interview question sharing
- Go language introduction, environment installation, basic structure
- leetcode746. 使用最小花费爬楼梯(简单)
- dried food! Reflection on the image migration of targeted confrontation
- People always simply think that the industrial Internet is a broader platform than the Internet
- STM32的内存扩展应用实现,小内存的单片机也能干大事(FSMC+SRAM)
- SQL Server 数据库之常量
- 攒机笔记二十:改造笔记本电脑(华硕A555L)
猜你喜欢
In the second half of the smart watch, opportunities and challenges coexist

中国 AI 的“黄埔军校”?MSRA 被曝停招“国防七子”及北邮学生

Leetcode interview question 17.16 Masseur (simple)

分享一个(快捷导航)

每周问答精选:PolarDB-X完全兼容MySQL吗?

2022年化工自动化控制仪表考试题库及在线模拟考试

Go语言简介,环境安装,基本结构

入参有汉字,报错500,服务器内部错误
![[ELT. Zip] openharmony paper club -- one article penetrates the forefront of Multimedia](/img/b3/01b168a1da0602d6c5b83489794a94.png)
[ELT. Zip] openharmony paper club -- one article penetrates the forefront of Multimedia
![[ELT. Zip] openharmony paper Club - you shouldn't miss these small landscapes](/img/a6/d8be8fb98e26199bceecb491282568.jpg)
[ELT. Zip] openharmony paper Club - you shouldn't miss these small landscapes
随机推荐
leetcode1025. Divisor game (simple)
儿子18岁上大学的时候我们已经60了,给他准备一笔钱买什么理财产品最靠谱?
第一阶段*第四章*项目管理一般知识
[interpretation of orb_slam2 source code] Analyze orb_ How does slam2 rgbd calculate the position and attitude in frame 0
中国海油上交所上市:市值6515亿 年利润703亿
Configure MySQL Cluster with MYCAT (2) -- configure MySQL master-slave replication
Weekly Q & A highlights: is polardb-x fully compatible with MySQL?
Android护眼功能,双非本科字节跳动Android面试题分享
【ELT.ZIP】《CCF开源高校行第一期》观后感
金鱼哥RHCA回忆录:RH358管理DNS和DNS服务器--DNS问题故障排除
[Mysql] CHAR_LENGTH函数
中一科技深交所IPO:市值83亿 湖北诞生又一家上市企业
ODPS SQL节点参数怎么设置呢?
Wireguard series (1): what is v * *?
徽商期货是正规平台吗?开户安全吗?
情报研判分析平台建设,情指勤一体化管理系统开发
静态路由综合实验
When our son was 18 years old and went to college, we were already 60. What financial products are the most reliable for him to buy?
php 一维数组去重
Android interview: event distribution 8 consecutive questions, Android basic interview questions