lundi 5 décembre 2016

Please explain error

#include <iostream>
using namespace std;
int main()
{
    int x[] = { 1 ,2 ,3 ,4 ,5 };
    int *ptr;
    ptr = &x;
    return 0;
}

The compiler tells me that '=': cannot convert from 'int (*)[5]' to 'int *'. What does this mean? The part I do not understand is that ptr being a pointer can always store the address of x that itself is a pointer that points to the base element of the array.

Aucun commentaire:

Enregistrer un commentaire