分配内存 [英] allocation of memory

查看:98
本文介绍了分配内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

请有人解释我何时何地为静态变量分配内存,这些变量在函数内声明,在所有函数(全局)之外声明的静态变量以及全局变量是不是静态的?

解决方案

所有这些类型的变量都在程序数据段中通过c启动代码保留并初始化它们,该启动代码在程序之后运行已经开始并且在进入main之前。


@Banfa


请向我解释一下我无法理解


一个常见的问题是不同的人对同一个概念使用不同的术语;或者更糟糕的是,不同概念的术语相同。也许您应该告诉我们您对内存分配的了解。然后我们可以小心地更仔细地说出答案。


此外,它有助于理解你提出这个问题的原因。你可能有一个更大的问题,我们可以直接解决。


banfa:太糟糕了我还没有完成你的建议。 ; - )

hello,
will someone please explain me when and where is memory allocated for static variables which are declared inside a function and static variable declared outside of all functions(global) and also for global variables which are not static?

解决方案

All those types of variables have data reserved and initialised for them in the programs data segment by the c start-up code which runs after the program has started and before main is entered.


@Banfa
please explain me a little more i cannot not understand


A common problem is for different people to use different terms for the same concept; or worse, the same term for different concepts. Perhaps you should tell us a little of what you understand about memory allocation. Then we can be careful to phrase the responses more carefully.

Also, it would help to understand why you are asking this question. You may have a larger issue that we could address directly.

banfa: too bad I don''t have any work done on your suggestion yet. ;-)


这篇关于分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆