what does cout << “\n”[a==N]; do?
问题 In the following example: cout<<"\n"[a==N]; I have no clue about what the [] option does in cout , but it does not print a newline when the value of a is equal to N . 回答1: I have no clue about what the [] option does in cout This is actually not a cout option, what is happening is that "\n" is a string literal. A string literal has the type array of n const char , the [] is simply an index into an array of characters which in this case contains: \n\0 note \0 is appended to all string literals