cout<<2["abc"]<<endl;
输出c。
不过这是什么语法啊,c++/c的,以前没遇到过,百度无果,有没有老司机带带啊。
伊谢尔伦2017-04-17 15:06:46
a[b]
is actually *(a + b)
so the above code is equivalent to
#include <iostream>
using namespace std;
int main(void) {
cout << *("abc"+2) << endl;
return 0;
}
Move a stackoverflow: http://stackoverflow.com/ques...
迷茫2017-04-17 15:06:46
This example is mentioned on page 144 of "C and Pointers", so I will just screenshot it for you. The author does not recommend writing it this way.
天蓬老师2017-04-17 15:06:46
Please ask the question under what circumstances did you encounter this problem? I'm a little curious about what this is.