当前位置:网站首页>Memory management of C
Memory management of C
2022-07-02 19:11:00 【Leisurely young heart】
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
typedef struct
{
int x;
int y;
}FTest;
int main() {
#if 0
char p[128];
strcpy(p,"tom");
printf("%s \n",p);
char* ptr = malloc(128*sizeof(char));// Allocate a space on the stack
FTest*pName=calloc(10, sizeof(FTest));// Allocate ten memories and all for 0
printf("%d \n\r", pName[4].x);
pName=realloc(pName,10+2*sizeof(FTest));// Reassign add two after FTest Size of memory
pName[12].x = 10;
printf("%d \n\r", pName[12].x);
if (ptr == NULL)
{
fprintf(strerror," Out of memory ");
exit(EXIT_FAILURE);
}
else
{
strcpy(ptr,p);
}
free(ptr);
#endif // 0
//memset and memcpy
char str[] = "IIII";
memset(str,'k', strlen(str));// Parameters : Array of settings , Replace character , Replace the first few
printf("%s \r\n", str);
// Chinese characters one Chinese character takes up two bytes, so copy 3 One can only be copied to half of the second
char dest[20] = " Autumn water stretches to the sky ";
char dest1[20] = {
0};
memcpy(dest1, dest,3);// autumn ?
printf("%s \r\n", dest1);
system("pause");
}
边栏推荐
- R语言使用epiDisplay包的lsNoFunction函数列出当前空间中的所有对象、除了用户自定义的函数对象
- 性能测试如何创造业务价值
- Introduction to the paper | analysis and criticism of using the pre training language model as a knowledge base
- Yolov3 trains its own data set to generate train txt
- LightGroupButton* sender = static_ cast<LightGroupButton*>(QObject::sender());
- R语言ggplot2可视化:gganimate包创建动态柱状图动画(gif)、使用transition_states函数在动画中沿给定维度逐步显示柱状图
- Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
- 新手必看,點擊兩個按鈕切換至不同的內容
- How to copy and paste interlaced in Excel
- [paper reading] Ca net: leveraging contextual features for lung cancer prediction
猜你喜欢

高级性能测试系列《24. 通过jdbc执行sql脚本》

In pytorch function__ call__ And forward functions

全志A33使用主线U-Boot
![[0701] [paper reading] allowing data imbalance issue with perforated input during influence](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [paper reading] allowing data imbalance issue with perforated input during influence

UML class diagram

juypter notebook 修改默认打开文件夹以及默认浏览器

【JVM调优实战100例】01——JVM的介绍与程序计数器

迷你高尔夫球场:伦敦休闲旅游好去处

Develop fixed asset management system, what voice is used to develop fixed asset management system

How can retail enterprises open the second growth curve under the full link digital transformation
随机推荐
Markdown基础语法
Excel如何进行隔行复制粘贴
数据降维——因子分析
聊聊电商系统中红包活动设计
【测试开发】一文带你了解什么是软件测试
The difference between interceptor and filter
新手必看,点击两个按钮切换至不同的内容
The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?
线程应用实例
Exness in-depth good article: dynamic series - Case Analysis of gold liquidity (V)
Stratégie touristique d'été de Singapour: un jour pour visiter l'île de San taosha à Singapour
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
论文导读 | 机器学习在数据库基数估计中的应用
使用CLion编译OGLPG-9th-Edition源码
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 网络安全专家 NSE 5
第一次去曼谷旅游怎么玩?这份省钱攻略请收好
What is 9D movie like? (+ common sense of dimension space)
Novice must see, click two buttons to switch to different content
How performance testing creates business value
R语言ggplot2可视化分面图(facet):gganimate包基于transition_time函数创建动态散点图动画(gif)