Examveda
Examveda

Determine Output:
void main()
{
      char *str1 = "abcd";
      char str2[] = "abcd";
      printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}

A. 2 5 5

B. 5 5 5

C. 2 4 5

D. 2 4 4

Answer: Option A

Solution(By Examveda Team)

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 '\0' termination character). The third sizeof is similar to the second one.


This Question Belongs to C Program >> C Miscellaneous

Join The Discussion

Comments ( 1 )

  1. GOKUL D
    GOKUL D :
    1 year ago

    the output is 8 5 5

Related Questions on C Miscellaneous