GATE Exam | Aptitude Questions | GATE Syllabus | GATE Result | Mock Test | GATE Preparation
0 votes
What is the value of
sizeof(a) /sizeof(char *)
in a code snippet:
char *a[4]={"sridhar","raghava","shashi","srikanth"};

Here a[4] is an array which holds the address of strings. Strings are character arrays themselves.
Memory required to store an address is 4 bits. So memory required to store 4 addresses is equal to 4*4=16 bits.
char *; is a pointer variable which stores the address of a char variable.
So sizeof(char *) is 4 bits. Therefore sizeof(a) /sizeof(char *) = 16/4 = 4 bytes.
asked in Programming by anonymous

Related questions

The best answer to any question