What will be the output of the following C code on a 32-bit system? [code] #include <stdio.h> void main() { char *a[10]

Thanh Thảo

New member
What will be the output of the following C code on a 32-bit system?
Code:
    #include <stdio.h>
    void main()
    {
        char *a[10] = {"hi", "hello", "how"};
        printf("%d\n", sizeof(a));
    }
A. 10
B. 13
C. Run time error
D. 40
 
Answer: d
Explanation: If the system is 32-bit system, then the size of pointer will be 4 bytes. For such a system, the size of array a will be 4x10 = 40 bytes. The size of pointer is 8 bytes on a 64 bit system. For the given array a of 10 elements, it will be 8x10 = 80 bytes.
 

Tìm kiếm

Back
Top