void main()
{
   char s[]="\12345s\n";
   printf("%d",sizeof(s));
}
When i compile it it giving 6. I am not geting why it is giving 6 insted of 8.
  Like {'\1','2','3','4','5','s','\n'}
Please can anybody tell the reason for this, I want some deep and clear explanation. I will be thankful to them.
Because \123 is considered one character, it's an escape sequence (octal). So sizeof calculates 5 characters '\123', '4', '5', 's', '\n',  and the ending '\0'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With