2 votes 2 votes #include <stdio.h> int main () { char *ptr = "\123456789\n"; printf("%s",ptr); } Can anyone explain what happend with escaping character before 1 ? Programming in C strings + – Shaik Masthan asked May 25, 2018 • reopened May 26, 2018 by Soumya29 Shaik Masthan 606 views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply ankitgupta.1729 commented May 26, 2018 reply Follow Share I think it is not duplicate question..both are different .. 1 votes 1 votes Soumya29 commented May 26, 2018 reply Follow Share "\123456789" Compiler considering \123 as an octal number. Its decimal equivalent is 83, which is ASCII value of $S$. That's why giving output - S456789 1 votes 1 votes ankitgupta.1729 commented May 26, 2018 reply Follow Share @soumya , but if we write 0 before any integer then it is considered as an octal number in C..it is not the case here..could u please explain ? 0 votes 0 votes Soumya29 commented May 26, 2018 reply Follow Share @ankit .. In C, all escape sequences consist of two or more characters, the first of which is the backslash, \ (called the "Escape Character"); the remaining characters determine the interpretation of the escape sequence. In this question, the compiler is taking it as \nnn where It's a valid escape sequence. An octal escape sequence consists of \ followed by one, two, or three octal digits. The octal escape sequence ends when it either contains three octal digits already, or the next character is not an octal digit. Check this 4 votes 4 votes ankitgupta.1729 commented May 26, 2018 reply Follow Share @soumya ,thank u so much ..I didn't know this thing... 0 votes 0 votes Soumya29 commented May 26, 2018 reply Follow Share @ankit .My pleasure :) Try some sequence like \999 - the compiler will give warning - Invalid escape sequence. If you try \656. It seems valid octal sequence but you will get a warning -octal escape sequence out of range. 1 votes 1 votes ankitgupta.1729 commented May 26, 2018 reply Follow Share @soumya ,yeah, it is showing , octal escape sequence out of range for 656..could u please explain why it is giving warning "octal escape sequence out of range" for 656 ? 0 votes 0 votes Soumya29 commented May 26, 2018 reply Follow Share The reason behind it is - Every escape sequence take 1-byte space. Now with 8 bits maximum 255 i.e '\377 is possible. 4 votes 4 votes ankitgupta.1729 commented May 26, 2018 reply Follow Share Thanks a lot @soumya... 0 votes 0 votes Please log in or register to add a comment.