当前位置:网站首页>从0到1理解c函数
从0到1理解c函数
2022-08-07 18:13:00 【youzjuer】
一、mmap函数
1、首先建立计算器存储概念,我的理解,就两部分:内存和文件,内存对应我们的数组,如果想操作内存中数据,通过对数组进行操作即可,如果对文件中数据操作,则需要通过read()函数读入到数组中,再进行操作

二、memcpy函数
此函数声明为
void *memcpy(void *str1, const void *str2, size_t n)
使用方法:
#include <stdio.h>
#include<string.h>
int main()
{
char *s="http://www.runoob.com";
char d[20];
memcpy(d, s+11, 6);// 从第 11 个字符(r)开始复制,连续复制 6 个字符(runoob)
// 或者 memcpy(d, s+11*sizeof(char), 6*sizeof(char));
d[6]='\0';
printf("%s", d);
return 0;
}一定要注意,如果dst声明为指针,则一定要用malloc为其分配空间。可以联想到,只要使用指针,必须要要malloc分配空间(或者直接声明为数组)。
边栏推荐
猜你喜欢

混合方式启动和销毁service梳理

What to do if there is no sound when watching TV on the computer

使用C语言实现静态顺序表

设置开机项的步骤 怎么设置开机启动项

Why does the computer show offline when printing? What should I do if the computer shows offline when printing?

Win7系统升级失败提示错误代码0X80070643如何解决

win7系统怎么激活 win7怎么激活系统

物联网技术概论:第7章

模块九(电商秒杀系统)

1. How a chip is born
随机推荐
File upload and download based on FTP protocol
【ROS2原理6】构架于DDS上的ROS2
win32&mfc————win32消息机制
分布式一致性协议 之 三阶段提交协议
tiup cluster restart
使用C语言实现静态顺序表
GC垃圾收集
05-树7 堆中的路径(最小堆)
tiup集群缩小
would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!
Win7 can't open the mobile hard disk what's wrong _ win7 can't open the mobile hard disk solution tutorial
What to do if the computer can't delete the folder
Kotlin coroutine createCoroutine and startCoroutine principle
调整台式电脑屏幕亮度的步骤 台式机显示器亮度怎么调
win7系统电脑更换锁屏壁纸的方法
带你认识npm和yarn
构建指标体系
tiup cluster patch
Timer,时间堆
企业文化如何治好企业“内耗”?