C Programming - Strings - Discussion

Discussion Forum : Strings - Find Output of Program (Q.No. 17)
17.
If the size of pointer is 32 bits What will be the output of the program ?
#include<stdio.h>

int main()
{
    char a[] = "Visual C++";
    char *b = "Visual C++";
    printf("%d, %d\n", sizeof(a), sizeof(b));
    printf("%d, %d", sizeof(*a), sizeof(*b));
    return 0;
}
10, 2
2, 2
10, 4
1, 2
11, 4
1, 1
12, 2
2, 2
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
31 comments Page 4 of 4.

Gouri Suders said:   1 week ago
Here, char *b is a pointer variable, so the number of bytes depends on the bitness of the system.
So if the system is 32, then the answer is 4.
If it is 64 bit system, then it is 8.
So, that's why here 4 bit, here they considered a 32-bit system.


Post your comments here:

Your comments will be displayed after verification.