mercredi 2 janvier 2019

why did const ptr only output one value in an array?

#include <iostream>
using std::cout;
using std::endl;
int main()
{

    int a[] = { 10,11 };
    int *const ptr = a;

    cout << "*ptr::" << *ptr << endl;
    cout << " ptr::" <<  ptr << endl;



    system("pause"); 
    return 0;
}

when i run it outputs: *ptr::10 ptr::00D3FB3C

i didn't understand why *ptr=10 and not 11 or why not both?

Aucun commentaire:

Enregistrer un commentaire