关于结构内存分配 [英] about structures memory allocation

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

问题描述

为以下结构分配了多少内存

struct bharath

{

int b;

char c;

浮动d;

}


以及如何?

how much memory is allocated for following structure
struct bharath
{
int b;
char c;
float d;
}

and how?

推荐答案

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

为以下结构分配了多少内存

struct bharath

{

int b;

char c;

浮动d;

}


以及如何?
how much memory is allocated for following structure
struct bharath
{
int b;
char c;
float d;
}

and how?



至少足以满足结构的总内存需求。

由于结构中的基本类型可能会有所不同从平台宽度

到平台和实现到实现(除了char,

课程)结构的大小也会有所不同。


你是如何做到的,或者如何在运行时分配内存?前者是

,只是为任何类型分配,真的。如果是后者,这很可能是具体的实施,至少基于我潜伏在这个新闻组中,

和我(差)的标准知识。

-

clvrmnky< mailto:sp ****** @ clevermonkey.org>


直接回复将被列入黑名单。替换spamtrap以我的名义来

直接与我联系。

Enough to fit at least the total memory requirements of the struct.
Since the primitive types in the struct can vary in width from platform
to platform and implementation to implementation (except char, of
course) the size of the struct will also vary.

How do you do it, or how is memory allocated at runtime? The former is
just allocating for any type, really. If the latter, this is likely
implementation specific, at least based on my lurking in this newsgroup,
and my (poor) knowledge of the Standard.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.


bh ******** @ gmail.com 说:

为以下结构分配了多少内存

struct bharath

{

int b;

char c;

float d;

}
how much memory is allocated for following structure
struct bharath
{
int b;
char c;
float d;
}



无。这是一种类型,而不是一个对象。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名, - www。

None. It''s a type, not an object.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


6月21日晚上7:33,Richard Heathfield< ; r ... @ see.sig.invalidwrote:
On Jun 21, 7:33 pm, Richard Heathfield <r...@see.sig.invalidwrote:

bharath ... @ gmail.com说:
bharath...@gmail.com said:

为以下结构分配了多少内存

struct bharath

{

int b;

char c;

浮动d;

}
how much memory is allocated for following structure
struct bharath
{
int b;
char c;
float d;
}



无。这是一种类型,而不是一个对象。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7 / 1999http://www.cpax.org.uk

电子邮件:rjh在上述域名, - www。


None. It''s a type, not an object.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.



让int大小为4B然后分配将是?

i想知道有关填充或其他相关信息的信息/>
填充?

let the int size is 4B then the allocation will be?
i want to know the info regarding padding or some other else related
to padding?


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

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