sizeof size_t

  • Thread starter Bill Cunningham
  • Start date
B

Bill Cunningham

I would like to check the sizeof size_t. Anyone have a suggestion?

Bill
 
M

Martin Ambuhl

Bill said:
I would like to check the sizeof size_t. Anyone have a suggestion?

You may kick yourself when you see how trivial this is:

#include <stdio.h>

int main(void)
{
printf("[Output]\n"
"For this implementation, sizeof(size_t) is %zu\n",
sizeof(size_t));
return 0;
}

[Output]
For this implementation, sizeof(size_t) is 4
 
M

Martin Ambuhl

MisterE said:
its a typedef so why can't you just do sizeof(size-t)

unless the variable 'size' and 't' are declared, the type of their
difference is not very well defined, is it?
 
V

vippstar

unless the variable 'size' and 't' are declared, the type of their
difference is not very well defined, is it?

Is it not?
#define size 42
#define t 6
As far as I know, 'size' and 't' in my example are not variables.
 
C

CBFalconer

Bill said:
I would like to check the sizeof size_t. Anyone have a suggestion?

size_t is a type. Therefore sizof needs it in parenthesis.

n = sizeof (size_t);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top