Because p
is of type int *
, so *p
is of type int
, which is apparently 4 bytes wide on your implementation.
And use %zu
for printing size_t
(what sizeof
yields) if you don’t want your program to invoke undefined behavior.
More Related Contents:
- How to find the ‘sizeof’ (a pointer pointing to an array)?
- Getting the size of a malloc only with the returned pointer
- C pointers and arrays/ ‘sizeof’ operator [duplicate]
- How to find the size of an array (from a pointer pointing to the first element array)?
- How can I return a character array from a function in C?
- Reliably determine the number of elements in an array
- C 3d array pointer decay with & and without &
- What is the output of the following code in C? [closed]
- whats the difference between dynamic memory allocation and normal memory allocation?
- Pointers program
- With arrays, why is it the case that a[5] == 5[a]?
- How come an array’s address is equal to its value in C?
- Why isn’t the size of an array parameter the same as within main?
- C sizeof a passed array [duplicate]
- What is the difference between char array and char pointer in C?
- In C, are arrays pointers or used as pointers?
- Array to pointer decay and passing multidimensional arrays to functions
- Difference between char *str=”STRING” and char str[] = “STRING”?
- What is guaranteed about the size of a function pointer?
- Returning Arrays/Pointers from a function
- why is array name a pointer to the first element of the array?
- Pointer vs array in C, non-trivial difference
- How can I find the number of elements in an array?
- Passing two-dimensional array via pointer
- Accesing a 2D array using a single pointer
- How to include a dynamic array INSIDE a struct in C?
- Access struct members as if they are a single array?
- C difference between *[] and **
- Find size of array without using sizeof
- C pointer notation compared to array notation: When passing to function