Top "Sizeof" questions

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

What's sizeof(size_t) on 32-bit vs the various 64-bit data models?

On a 64-bit system, sizeof(unsigned long) depends on the data model implemented by the system, for example, it is 4 …

c 64-bit sizeof size-t
Element count of an array in C++

Let's say I have an array arr. When would the following not give the number of elements of the array: …

c++ arrays sizeof
what is the size of an enum type data in C++?

This is a C++ interview test question not homework. #include <iostream> using namespace std; enum months_t { january, …

c++ enums sizeof
Is the sizeof(some pointer) always equal to four?

For example: sizeof(char*) returns 4. As does int*, long long*, everything that I've tried. Are there any exceptions to this?

c++ c pointers memory sizeof
How do I find the size of a struct?

struct a { char *c; char b; }; What is sizeof(a)?

c struct sizeof
C sizeof char* array

I have a char* array as follows: char *tbl[] = { "1", "2", "3" }; How do I use the sizeof operator to get the number …

c sizeof
Why do I get a warning every time I use malloc?

If I use malloc in my code: int *x = malloc(sizeof(int)); I get this warning from gcc: new.c:7: …

c gcc malloc warnings sizeof
Size of int and sizeof int pointer on a 64 bit machine

I was just wondering how can I know if my laptop is 64 or 32 bit machine. (it is a 64). So, I …

c++ c int 64-bit sizeof
Is sizeof(bool) defined in the C++ language standard?

I can't find an answer in the standard documentation. Does the C++ language standard require sizeof(bool) to always be 1 (…

c++ boolean sizeof implementation-defined-behavior
How do sizeof(arr) / sizeof(arr[0]) work?

When looking for a size of an array in a for loop I've seen people write int arr[10]; for(int …

c++ sizeof