回忆 [英] Memories

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

问题描述

亲爱的。


据我所知,然后记忆分为三个部分


1.堆;

2.堆栈;

3.数据segmnet;


但是我没有得到差异和
行为

这些,任何人都可以了解这一点。


为什么我们得到堆栈超过流量?好像我写了一个简单的

代码


int main(){


int(* main_ptr)( void);

main_ptr = main;

printf("%s \ n",Hi);

(* main_ptr)( );

返回0;


}


现在编写代码时要考虑的步骤是什么所以我

可能无法超过流量(检查可能没有堆栈超过

流量)


Thnaks提前

问候

Ranjeet

Dear All.

As far as i know that Then memeory is divided into the three segements

1. Heap;
2. Stack;
3. Data segmnet;

But I am not getting the exact picture of the diffrence and the
behaviour
of these, Can any one shed there knowledge on this.

And why we get the stack over flow ? As if I write a simple
code

int main () {

int (*main_ptr) (void);
main_ptr = main;
printf("%s\n", Hi);
(*main_ptr)();
return 0;

}

Now what are the steps to be considerd while writing the code so that I
may not get the stack over flow (To check there may not be stack over
flow)

Thnaks In Advance
Regards
Ranjeet

推荐答案

关于你的第一个breezer问题


堆栈segement由局部变量和函数调用

存储形式参数。以递归为例,它有一个固有的

要求,用于存储函数调用的堆栈数据结构,它们被调用,然后从每个函数返回他们在

的逆序中。每个函数调用都使用堆栈段上的一个区域。


堆是程序动态分配内存到
不同变量的地方。


数据段包含程序的通用数据存储要求..

a breezer regarding your first question

stack segement is used by the local variables and the function calls to
store formal parameters. take recursion for example, it has an inherent
requirement for a stack data-structure to store function calls in the
order that they are called and then return from each one of them in a
reverse order. Each function call uses an area on the stack segment.

heap is the place from where the program dynamically allocate memory to
different variables.

data segment contains common data storage requirement of a program..


到第二个问题......


每个程序都有资源限制。每个程序只能使用有限的

内存量。在您的代码片段中,您递归地调用函数main

,而没有返回按钮。来自递归的条件。由于

a结果,程序不断将函数调用推送到堆栈

,直到它最终导致堆栈覆盖。

to the second question ...

each program has a resource limit. Each program can only use a limited
amount of memory. In your code fragment, you are calling funtion "main"
recursively, without having a "return" condition from the recursion. As
a result , the program keeps pushing the function calls to the stack
till it ultimately results in a stack overfolw.


ra *********** @ gmail.com 写道:

据我所知,那时记忆分为三个部分

1.堆;
2.堆栈;
3.数据分段;

但我没有得到差异的确切图片和

As far as i know that Then memeory is divided into the three segements

1. Heap;
2. Stack;
3. Data segmnet;

But I am not getting the exact picture of the diffrence and the




你需要两个拼写检查并阅读C标准。当你执行

时,请告诉我们你在哪里找到堆,堆栈或数据段

提到。


-

"如果你想通过groups.google.com发布一个后续内容,请不要使用

破损的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson



You need both a spelling checker and to read the C standard. When
you do, please tell us where you find heap, stack, or data segment
mentioned.

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


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

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