C | Advanced Pointer | Question 2
Assume sizeof an integer and a pointer is 4 byte. Output?
#include <stdio.h> #define R 10 #define C 20 int main() { int (*p)[R][C]; printf("%d", sizeof(*p)); getchar(); return 0; } |
chevron_right
filter_none
(A) 200
(B) 4
(C) 800
(D) 80
Answer: (C)
Explanation: Output is 10*20*sizeof(int) which is “800″ for compilers with integer size as 4 bytes.
When a pointer is de-referenced using *, it yields type of the object being pointed. In the present case, it is an array of array of integers. So, it prints R*C*sizeof(int).
Quiz of this Question
Recommended Posts:
- C | Advanced Pointer | Question 1
- C | Advanced Pointer | Question 10
- C | Advanced Pointer | Question 5
- C | Advanced Pointer | Question 3
- C | Advanced Pointer | Question 9
- C | Advanced Pointer | Question 4
- C | Advanced Pointer | Question 8
- C | Advanced Pointer | Question 7
- Double Pointer (Pointer to Pointer) in C
- C++ | this pointer | Question 5
- C++ | this pointer | Question 4
- C++ | this pointer | Question 3
- C++ | this pointer | Question 1
- C++ | this pointer | Question 2
- What is a Pointer to a Null pointer



