Page 68 near the top - type size_t


#1

Hello everyone

On the top of page 68 just under the code we have this sentence:

The sizeof() function returns a value of type size_t, for which %zu is the correct placeholder token.

I’m not sure what ‘type size_t’ stands for.

JR


#2

size_t is just an alias (another name) for the unsigned long type.

Also, calling sizeof () a function is an error; sizeof () is not a function, it is a unary operator.


#3

Thank you ibex10

I am grateful for you fast answer.

However, I am puzzled by your second point you made about the sizeof() is a unary operator and not a function.

According to the book here the sizeof() IS a function! The sentence below is a direct quote from the top of page 68

Take a look at the book and tell me what you think.

[color=#004080]JR[/color]


#4

[quote]According to the book here the sizeof() IS a function! The sentence below is a direct quote from the top of page 68

Take a look at the book and tell me what you think.
[/quote]
That’s an oversight.

If something is a function, you can evaluate its address.

Compile this:

printf ("%p\n", printf);

Now, try compiling this:

printf ("%p\n", sizeof);

[Become a competent programmer faster than you can imagine: pretty-function.org]