24,854
社区成员
发帖
与我相关
我的任务
分享
int main(void)
{
cout <<123 <<endl;
test.c:14:1: error: pasting "'1'" and "'2'" does not give a valid preprocessing token
test.c:14:1: error: pasting "'2'" and "'3'" does not give a valid preprocessing token
cout <<'1''2''3' <<endl; // 非法
test.c:15:1: error: pasting ""1"" and ""2"" does not give a valid preprocessing token
test.c:15:1: error: pasting ""2"" and ""3"" does not give a valid preprocessing token
cout <<"1""2""3" <<endl; // 这个相当于"123"。 g++的预处理器虽然给出了结果,但是编译不过
test.c:16:1: error: pasting ""aa"" and ""bb"" does not give a valid preprocessing token
test.c:16:1: error: pasting ""bb"" and ""cc"" does not give a valid preprocessing token
cout <<"aa""bb""cc" <<endl; // 这个相当于"aabbcc"。 g++的预处理器虽然给出了结果,但是编译不过
cout <<aabbcc <<endl; // 非法
cout <<abc123 <<endl; // 非法
cout <<123 +1 <<endl;
cout <<"123"+1 <<endl; // "123"是一个指向'1'的字符指针,加一之后就指向'2',所以输出23
return 1;
}
int main(void)
{
cout <<123 <<endl;
test.c:14:1: error: pasting "'1'" and "'2'" does not give a valid preprocessing token
test.c:14:1: error: pasting "'2'" and "'3'" does not give a valid preprocessing token
cout <<'1''2''3' <<endl;
test.c:15:1: error: pasting ""1"" and ""2"" does not give a valid preprocessing token
test.c:15:1: error: pasting ""2"" and ""3"" does not give a valid preprocessing token
cout <<"1""2""3" <<endl;
test.c:16:1: error: pasting ""aa"" and ""bb"" does not give a valid preprocessing token
test.c:16:1: error: pasting ""bb"" and ""cc"" does not give a valid preprocessing token
cout <<"aa""bb""cc" <<endl;
cout <<aabbcc <<endl;
cout <<abc123 <<endl;
cout <<123 +1 <<endl;
cout <<"123"+1 <<endl;
return 1;
}