当前位置:网站首页>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语言dplyr包rowwise函数、mutate函数计算dataframe数据中多个数据列在每行的最大值、并生成行最大值对应的数据列(row maximum)
- The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?
- ICDE 2023|TKDE Poster Session(CFP)
- 使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星
- Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
- 2022编译原理期末考试 回忆版
- R语言ggplot2可视化:可视化折线图、使用labs函数为折线图添加自定义的X轴标签信息
- 拦截器与过滤器的区别
- Progress-进度条
- Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent
猜你喜欢

【JVM调优实战100例】03——JVM堆调优四例

The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?

Mini Golf Course: a good place for leisure and tourism in London

Imitation Jingdong magnifying glass effect (pink teacher version)

PyTorch函数中的__call__和forward函数

在纽约寻找童真——新泽西州乐高乐园探索中心的美好一天

新手必看,點擊兩個按鈕切換至不同的內容

使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星

Have you stepped on the nine common pits in the e-commerce system?

Mysql高级篇学习总结6:索引的概念及理解、B+树产生过程详解、MyISAM与InnoDB的对比
随机推荐
Excel finds the same value in a column, deletes the row or replaces it with a blank value
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 網絡安全專家 NSE 5
Date tool class (updated from time to time)
在纽约寻找童真——新泽西州乐高乐园探索中心的美好一天
High frequency interview questions
新加坡暑假旅游攻略:一天玩转新加坡圣淘沙岛
[fluent] dart data type (VaR data type | object data type)
Develop fixed asset management system, what voice is used to develop fixed asset management system
ORA-01455: converting column overflows integer datatype
Hospital online inquiry source code hospital video inquiry source code hospital applet source code
R language ggplot2 visual Facet: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)
高级性能测试系列《24. 通过jdbc执行sql脚本》
全志A33使用主线U-Boot
使用CLion编译OGLPG-9th-Edition源码
C file input operation
codeforces每日5题(均1700)-第四天
R language dplyr package Na_ The if function converts the control in the vector value into the missing value Na, and converts the specified content into the missing value Na according to the mapping r
MySQL advanced learning summary 7: MySQL data structure - Comparison of hash index, AVL tree, B tree and b+ tree
R语言dplyr包filter函数筛选dataframe数据、如果需要筛选的数据列(变量)名称中包含引号则需要使用!!sym语法处理、否则因为无法处理引号筛选不到任何数据
为什么要做企业固定资产管理系统,企业如何加强固定资产管理