sizeof运行时的dataTypes [英] sizeof dataTypes at run time

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

问题描述

大家好,


可以在运行时计算任何标准数据类型的大小

时间,即不使用sizeof()运算符


谢谢和问候,

拉曼

解决方案

" Raman" ; < ramanchalo ... @ gmail.comwrote:


可以在

运行时计算任何标准数据类型的大小,即不使用sizeof()运算符

http://groups.google.com/group/comp....rch+this+group


-

彼得


拉曼说:
< blockquote class =post_quotes>
大家好,


可以在运行时计算任何标准数据类型的大小

时间即没有使用sizeof()运算符



当然 - 这很简单,因为没有

sizeof()运算符。您所要做的就是实例化类型,并在结果对象上使用

sizeof运算符。通过这种方式,您甚至可以避免使用某人错误地描述为

sizeof()运算符的外观。


-

Richard Heathfield

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

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


3月26日上午10:54,拉曼 ; < ramanchalo ... @ gmail.comwrote:


大家好,


可以计算任何大小运行时的标准数据类型

时间即不使用sizeof()运算符


谢谢和问候,

拉曼



大家好,


U甚至不知道它的类型是什么,可以获得任何变量的大小

或它在哪里使用。下面将解释这种方式作为一个例子。


int a;

printf(变量的大小是%d \ n,(& a + 1) - (& a));


这适用于所有数据类型(即使是数组)。


问候

jamsheed m(ja ******* @ gmail.com)


Hi All,

Is ut possible to calculate size of any standard data types at run
time i.e without using sizeof() operator

Thanks and Regards,
Raman

解决方案

"Raman" <ramanchalo...@gmail.comwrote:

Is ut possible to calculate size of any standard data types at
run time i.e without using sizeof() operator

http://groups.google.com/group/comp....rch+this+group

--
Peter


Raman said:

Hi All,

Is ut possible to calculate size of any standard data types at run
time i.e without using sizeof() operator

Sure - and this is especially easy since there is no such thing as the
sizeof() operator. All you have to do is instantiate the type, and use
the sizeof operator on the resulting object. This way, you avoid even
the appearance of using what someone has mistakenly described as a
sizeof() operator.

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


On Mar 26, 10:54 am, "Raman" <ramanchalo...@gmail.comwrote:

Hi All,

Is ut possible to calculate size of any standard data types at run
time i.e without using sizeof() operator

Thanks and Regards,
Raman

Hi All,

U can get a sizeof any variable without even knowing what is its type
or where it is used. The way is explained below as an example.

int a;
printf("size of variable is %d\n",(&a+1)-(&a));

This is applicable for all datatypes(even for array).

Regards
jamsheed m(ja*******@gmail.com)


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

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