254 views
0 votes
0 votes

Ans : Option D 

But array size is 14 then how 15 is printed ?

ptr size is 2 but precise answer given was 2.29 , how ?

 

1 Answer

0 votes
0 votes

sizeof will counts the null character also, while strlen stops when it encounter null character

In below image you can see "a\0bc" will be actually interpreted as "a\0bc\0" i.e compiler automatically adds null character at end of string.

So you are getting 15 although its 14

 

 

 

Related questions

0 votes
0 votes
1 answer
1
HeadShot asked Dec 11, 2018
824 views
What if the "||" is replaced with "&&" ? ( What does former condition in "if" results and how ?)
0 votes
0 votes
0 answers
2
HeadShot asked Dec 11, 2018
399 views
Answer : Option A Doubt : 0 repeated n-1 times and a single 1 , then how <0,n ?
0 votes
0 votes
2 answers
3
HeadShot asked Dec 11, 2018
373 views
Why 50 * 3 and not 50+3 ?Does every Byte requires different instruction ?
0 votes
0 votes
0 answers
4
HeadShot asked Dec 11, 2018
351 views
Answer : Option C Please explain ( Why do we need to assume that there were seperate tables related to customer and store ? )