I was learning about pointer in cpp and I write this code but when I run this code the outcome was different from what I expected but why ?
#include <iostream>
using namespace std;
int main()
{
char chars[] = {'a','b','g','j','z'};
char *ptr1 = chars;
cout << ptr1 << endl;
int arr[] = {1,2,3,4,5};
int *ptr2 = arr;
cout << ptr2;
return 0;
}
the output of this code is :
abgjz
0x7ffd836e4360
why the first pointer printed the whole character array but the second pointer printed the address only ?
I want to print the address of both arrays.