- 11
- 0
- 约1.05万字
- 约 17页
- 2017-09-07 发布于河南
- 举报
动态指针数组,释放内存问题(Dynamic pointer array, freeing memory problems)
动态指针数组,释放内存问题(Dynamic pointer array, freeing memory problems)
C language memory allocation and release (construction of multidimensional dynamic arrays) (2012-02-29 00:17)
Tags: C language memory dynamic classification: C/C++
A static and dynamic array array.
Static array is more common, the length of the array of predefined, throughout the program, once a given size cannot be changed after the length of static memory array themselves responsible for the release of occupation.
Dynamic array length can be with the program needs to specify the size. The array of dynamic memory allocation function (malloc) from the stack (heap) on the allocation of storage space, only when the program execution allocation function, to allocate memory for it at the same time, the programmer is responsible for releasing the allocated memory (free).
Two. Why do you want to use a dynamic array?
In practice, often this happens, the required memory space depends on the actual input data, and cannot be determined in advance. For this problem, it is difficult to solve by static array method. In order to solve the above problems, the C language provides some memory management functions, these memory management functions with the pointer can be dynamically allocated memory space, to build a dynamic array, but also the space for recovery is no longer in use, provides a means for the effective use of memory resources.
Three. Compared with the static dynamic array array
For static array, its creation is very convenient, there is no need to use after the release, but also create references to the simple, unable to change its size is its fatal weakness!
For a dynamic array, it creates trouble, after use must be released by the programmers themselves, otherwise will cause serious memory leaks. But its use is very flexible, according to the procedures need to be dynamically allocated size.
Four. How to build a dynamic array?
Construction of dynamic array, we follow the following principles:
When the ap
您可能关注的文档
- 分数四则混合运算(Mixed arithmetic of fraction four).doc
- 分数混合运算(Fractional mixed operation).doc
- 分析人力资源经理发展的四个阶层(Analyze the four levels of human resource manager development).doc
- 分析化学部分练习题(Some exercises in Analytical Chemistry).doc
- 分析化学(analytical chemistry).doc
- 分析文章结构入门(An introduction to the structure of the article).doc
- 分析数据中心机房pue值偏高问题及解决方案_机房360_中国绿色数据中心(The problem of high pue value and analysis of the data center solutions _ China green data center room 360_).doc
- 分析评议阶段个人工作总结(Analysis, evaluation stage, personal work summary).doc
- 分析评议阶段工作进展情况汇报(Report the progress of analysis and evaluation stage).doc
- 分析飞力公司战略目标与绩效管理之间的脱节(Analysis of the gap between strategic objectives and performance management of the company's fame).doc
- 动漫简史(A brief history of animation).doc
- 动漫风景线(Cartoon scenery line).doc
- 动漫语录(Anime quotations).doc
- 动物生物化学试题(Animal biochemistry questions).doc
- 加涅的累积学习理论(Gagne's theory of cumulative learning).doc
- 动画剧本创作步骤(Animation steps).doc
- 动画文献综述(Animation literature review).doc
- 动画概论2 动画的形态系统(Outline of animation 2 animation form system).doc
- 动画片前期制作的任务和具体内容(The tasks and specific contents of the early stage animation production).doc
- 努尔哈赤(Nur Ha Che).doc
最近下载
- DB37T 4984-2025无人机无半航空瞬变电磁探测技术规程.pdf VIP
- 机电安装专业验收资料表格大全.docx VIP
- GB-T 13377-2010 原油和液体或固体石油产品 密度或相对密度的测定.pdf
- 计量检定设备采购项目组织机构及人员配备.doc VIP
- 招标代理机构选取各项管理规章制度.docx VIP
- 华东交通大学2010—2011学年考试卷《复变函数》期末试卷.doc VIP
- 最全临床输血过程质量管理监控与效果评价制度与流程.pdf VIP
- 一种石墨电极拧紧方法.pdf VIP
- DB37-T4984-2025无人直升机高精度磁测技术规程.pdf VIP
- 胆囊结石B超报告.doc VIP
原创力文档

文档评论(0)