当前位置:网站首页>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");
}
边栏推荐
- [0701] [paper reading] allowing data imbalance issue with perforated input during influence
- 云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
- 使用CLion编译OGLPG-9th-Edition源码
- codeforces每日5题(均1700)-第四天
- "Patient's family, please come here" reading notes
- R语言使用epiDisplay包的lrtest函数对多个glm模型(logisti回归)执行似然比检验(Likelihood ratio test)对比两个模型的性能是否有差异、广义线性模型的似然比检
- 2022 software engineering final exam recall Edition
- mybatiesHelperPro工具必须的可以生成到对应项目文件夹下
- 新手必看,點擊兩個按鈕切換至不同的內容
- MySQL advanced learning summary 7: MySQL data structure - Comparison of hash index, AVL tree, B tree and b+ tree
猜你喜欢
![[test development] software testing - concept](/img/24/9ee885d46f7200ae7449957ca96b9d.png)
[test development] software testing - concept

According to the atlas of data security products and services issued by the China Academy of information technology, meichuang technology has achieved full coverage of four major sectors

Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management

How to clean up discarded PVs and their corresponding folders

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

Excel finds the same value in a column, deletes the row or replaces it with a blank value

Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent

Deep learning mathematics foundation
![[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference

电商系统中常见的 9 大坑,你踩过没?
随机推荐
2022编译原理期末考试 回忆版
QT中的QPropertyAnimation使用和toast案列
线程应用实例
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 网络安全专家 NSE 5
Stratégie touristique d'été de Singapour: un jour pour visiter l'île de San taosha à Singapour
High frequency interview questions
PHP非对称加密方法私钥及公钥加密解密的方法
【测试开发】一文带你了解什么是软件测试
新手必看,點擊兩個按鈕切換至不同的內容
FastDFS安装
Mini Golf Course: a good place for leisure and tourism in London
Introduction to the paper | application of machine learning in database cardinality estimation
虚拟机初始化脚本, 虚拟机相互免秘钥
Mysql高级篇学习总结7:Mysql数据结构-Hash索引、AVL树、B树、B+树的对比
数字滚动带动画
mybatiesHelperPro工具必须的可以生成到对应项目文件夹下
R language uses the lsnofunction function function of epidisplay package to list all objects in the current space, except user-defined function objects
Emmet basic syntax
Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
R language ggplot2 visual Facet: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)