+ 3
when we pass the string in the sizeof() operator ,it always gives 1 more from the letters present in the string......
{int a; a=sizeof("ankit"); cout<<a;} //why its giving 6 as answer...
7 ответов
+ 7
i think due to null char(\0) present at end of string..
when a string create compiler set a null char to determine ending string.. and sizeof func also cont that too.. thats why ans 6,,,
+ 7
null char is not a normal char that print its just a terminal point to determine ending point of any string,
+ 5
don't say thank you.help to another three people and tell them help other three people,small help do big impact ☺
+ 3
Every string in c++ is in the memory ended with zero character '\0'.
So your string looks like "ankit\0".
So its length is 6.
+ 2
yes i will definitely do this...
the impact will be big
+ 1
thanks...
but when we want to print the null character..
it does not printed...and in the place of null character the space prints..and the curser blinks after the space ...
+ 1
👍👍 thanks