char p[]="abc\012\0x34";
printf("%d\n",strlen(p));
I am getting output 4. Shouldn’t it be 3 ???
Although for following i am getting 3.
char p[]="abc\0";
printf("%d\n",strlen(p));
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your string does contain four characters before the
\0, i.e.abcand\012.The latter is a valid octal escape sequence, which is 10 in decimal, i.e an ASCII linefeed character.
\0x34on the other hand isn’t valid octal – only the\0part is valid hence that’s the real end of your NUL terminated string.