c 语言 sizeof函数原型,c语言函数sizeof(C language function sizeof).doc

c语言函数sizeof(C language function sizeof)

c语言函数sizeof(C language function sizeof)

Sizeof C language is a unary operator, such as C + + language, other operators -- etc.. It is not a function. The sizeof operator gives the storage size of its operands in bytes. Operands can be either an expression or a type name enclosed in parentheses. The storage size of operands is determined by the type of operand.

Two, sizeof usage

1, for data types

Sizeof uses the form: sizeof (type)

Data types must be enclosed in parentheses. Such as sizeof (int).

2. Used of variables

Sizeof uses the form: sizeof (var_name) or sizeof var_name

Variable names can be enclosed without parentheses. Such as sizeof (var_name), sizeof, var_name and so on are in the correct form. Parentheses are used more widely, and most programmers adopt this form.

Note: the sizeof operator cannot be used for function types, incomplete types, or bit fields. An incomplete type is a data type with an unknown storage size, such as an array type of unknown storage size, the structure of the unknown content, or the union type, the void type, and so on.

If sizeof (max), if the variable Max is defined as int max (), sizeof (char_v), if the char_v is defined as "char char_v [MAX]" and "MAX" is unknown at this point, the sizeof (void) is not the correct form.

Three, sizeof results

The result type of the sizeof operator is size_t, which is typedef int type in the header file unsigned. This type is guaranteed to hold the byte size of the established maximum object.

1, if operands have type char, unsigned, char, or signed char, the result is equal to 1.

ANSI C specifies that the character type is 1 bytes.

2, int, unsigned int, short int, unsigned short, long int, unsigned long, float, double, long, double type of sizeof is not specified in the ANSI C, the size depends on the implementation, the general may respectively 2, 2, 2, 2, 4, 4, 4, 8, 10.

3, when operands are pointers, sizeof relies on the compiler. For example, in Microsoft C/C++7.0, the near class pointer byte

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值