1108
The
1109
The
1110 The size is determined from the type of the operand.
1111 The result is an integer.
1112 If the type of the operand is a variable length array type, the operand is evaluated;
1113 otherwise, the operand is not evaluated and the result is an integer constant.
1114
When applied to an operand that has type
1115 When applied to an operand that has array type, the result is the total number of bytes in the array.85)
1116 When applied to an operand that has structure or union type, the result is the total number of bytes in such an object, including internal and trailing padding.
1117
The value of the result is implementation-defined, and its type (an
unsigned integer type) is
1118
EXAMPLE 1
A principal use of the
extern void *alloc(size_t);
double *dp = alloc(sizeof *dp);
The implementation of the
1119
EXAMPLE 2
Another use of the
sizeof array / sizeof array[0]
1120 EXAMPLE 3 In this example, the size of a variable length array is computed and returned from a function:
#include
size_t fsize3(int n)
{
char b[n+3]; // variable length array
return sizeof b; // execution time sizeof
}
int main()
{
size_t size;
size = fsize3(10); // fsize3 returns 13
return 0;
}
1121
85) When applied to a parameter declared to have array or function
type, the
1122
Forward references:
common definitions
Next
Created at: 2005-06-29 02:18:59
The text from WG14/N1124 is copyright © ISO