I'm using C++ to understand how exactly pointers work. I have this piece of code using arrays, which I'm using just to understand how the equivalent works with pointers.
int main() {
int arr[10] = {1,2,3};
char arr2[10] = {'c','i','a','o',''};
cout << arr << endl;
cout << arr2 << endl;
}
However when I run this, arr
outputs the address of the first element of the array of ints (as expected) but arr2
doesn't output the address of the first element of the array of chars; it actually prints "ciao".
What is it that I'm missing or that I haven't learned yet about this?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…