Q32
Determine Output: main() char *str1 = "abcd"; char str2[] = "abcd"; printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
A.
2 5 5
B.
2 4 4
C.
8 5 5
AnswerD.
2 4 5
Answer: Option C
Solution
Answer: Option C
Solution:
In first sizeof, str1 is a character pointer so it gives you the size of the pointer variable. In second sizeof the name str2 indicates the name of the array whose size is 5 (including the 'null' termination character). The third sizeof is similar to the second one.