如何在C中实现sizeof运算符 [英] How to implement sizeof operator in C

查看:82
本文介绍了如何在C中实现sizeof运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁能告诉我如何在C语言中实现sizeof

Can anyone tell me how to implement sizeof in C language

推荐答案


谁能告诉我如何实现C语言中的sizeof
Can anyone tell me how to implement sizeof in C language



已经有了它的实现。您想使用它还是创建自己的?

There already is an implemenation of it. Do you want to use it or to create your own?


yes ..我想编写一个提供相同功能的函数...
yes.. I want to write a function which provide the same functionality...


由于你不能写一个以类型作为参数的函数,你将无法做你想做的事。


你可以以编程方式获取类型的大小但是代码必须特定于类型。


sizeof运算符存在,因为没有真正的其他方式来获得它提供的功能,它是有用的。
Since you can not write a function that takes a type as an argument you will not be able to do what you wish.

You can get the size of a type programatically but the code would have to be specific to the type.

The sizeof operator exists because there is no real other way to get the functionality it provides and it is something that is useful.


这篇关于如何在C中实现sizeof运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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