Pointer can become array ?

Example if i write int* a;
a[10]=5;can ?
It is possible once you enter an address in a, I think. But it is not a good practice and you shouldn't do it. Because the compiler might overwrite the data when you create an another variable. Instead you should try using the pointer with the new operator and then you can do it.
You can use array syntax with pointers.

a[10] is the same as *(a + 10). It accesses the 10:th int after the int pointed to by a. If a is pointing to the first element in an array it means it will access the 11:th element in the array.
Last edited on
Topic archived. No new replies allowed.