?
Determine Output:
Determine Output:
main()
{
char *str1 = "abcd";
char str2[] = "abcd";
printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}
main()
{
char *str1 = "abcd";
char str2[] = "abcd";
printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}
Answer & Solution
Correct Answer:
Option
C
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.
Join the Discussion
Login to post a comment or share your explanation.
LoginCan you explain how it 8 5 5
sizeof(char *) is the size of the pointer, so normally 4 for 32-bit machine, and 8 for 64-bit machine.