+ 2
could someone explain this?
// why a = 0x28ff10 ? // what is *(a + 2) doing ? #include <iostream> using namespace std; int main() { int a[4] = {1,2,3,4}; cout << a << endl << *(a + 2) << endl << 0x28ff10; }
4 ответов
+ 2
cout<<a; is giving you location of a[0] and cout <<*(a+2); is giving you value at a[2]
+ 1
0x28ff10 is a hexadecimal number literal (can be recognized by the leading "0x" that just states that the following literal is hexadecimal, i.e. to the base of 16).
0
Thanks to both
0
How is (a + 2) possible? It sounds like it's trying to add the literal 2 to an array of integers which should spit out a compilation error.