Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created April 5, 2012 15:33
Show Gist options
  • Save darkhelmet/2311981 to your computer and use it in GitHub Desktop.
Save darkhelmet/2311981 to your computer and use it in GitHub Desktop.
C sizeof operator
To be pedantic, C sizeof doesn't operate on types either. The sizeof
operator applies to an expression or - this is the tricky bit - a type
cast.
thus
sizeof i
but also
sizeof(int)
but not
sizeof int
People think C sizeof is a function but it's an operator; the
expression sizeof(int) parses differently from the way most people
interpret it.
We're getting off topic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment