Today I met a pen question from a company (despised ):
Char s [] = "\ 141 \ 141abc \ t"; cout <S <Endl; cout <strlen (s) <Endl; // What is the output result?
Answer:
\ 141 AABC
9
(If you are a big bull, you will know the answer and the following things will not look at it, just put your younger brother in the dark and don't despise me)
The first two characters are familiar to everyone. It must be a single character. The last 141 character is three characters. But when it comes to the \ 141 character, I am confused. How many characters are there? Actually
\ 141 is a character a. Why? Because \ 141 is a character representation with Octal numbers, \ O \ oo \ OOO three forms, of course, O must be the correct octal number (0 ~ 7 ).
So if we change s like this:
S [] = "\\ 141 \ 411abc \ t ";
The result is \ 141! 1abc, because \ 41 is! Character
Another problem is that the strlen () function is not counted as \ 0 ..