Top "Sizeof" questions

sizeof refers to the Standard C/C++ operator for returning the size in bytes of an expression or datatype.

Are there machines, where sizeof(char) != 1, or at least CHAR_BIT > 8?

Are there machines (or compilers), where sizeof(char) != 1? Does C99 standard says that sizeof(char) on standard compliance implementation MUST …

c char standards sizeof c99
Why are C character literals ints instead of chars?

In C++, sizeof('a') == sizeof(char) == 1. This makes intuitive sense, since 'a' is a character literal, and sizeof(char) == 1 as …

c++ c char sizeof
How to determine the size of an array of strings in C++?

I'm trying to simply print out the values contained in an array. I have an array of strings called 'result'. …

c++ arrays string sizeof cout
how to find length of an unsigned char pointer in C?

I want to find size or length of an unsigned char pointer in a function where that pointer is an …

c arrays sizeof strlen
Why is int typically 32 bit on 64 bit compilers?

Why is int typically 32 bit on 64 bit compilers? When I was starting programming, I've been taught int is typically the …

c++ compiler-construction int sizeof platform
Is there a bit-equivalent of sizeof() in C?

Sizeof() doesn't work when applied to bitfields: # cat p.c #include<stdio.h> int main( int argc, char **…

c sizeof bit-fields
how to get byte size of type in generic list?

I have this generic list and I want to get the byte size of the type like if T is …

c# list byte sizeof generic-list
Why does a C-Array have a wrong sizeof() value when it's passed to a function?

Complete example: #include <stdio.h> void test(int arr[]) { int arrSize = (int)(sizeof(arr) / sizeof(arr[0])); printf("%d\…

c arrays function sizeof
What does sizeof(&array) return?

Following the question: How come an array's address is equal to its value in C? #include <stdio.h> #…

c string pointers sizeof
"C" sizeof with a type or variable

Recently saw someone commending another user on their use of sizeof var instead of sizeof(type). I always thought that …

c coding-style sizeof