I have written this code, which should move my array by 1:
// Declare and initialize Array
int temp;
int dim[5] = { 6, 7, 8, 9, 10 };
int array_size = sizeof(dim) / sizeof(dim[0]);
cout << "Array-Size: " << dim[array_size - 1] << endl;
// Move by 1 position
for (int i = 0; i < (array_size - 1); i++)
{
temp = dim[array_size - 1];
dim[array_size - 1] = dim[i];
dim[i] = temp;
}
// Console Output
for (int i = 0; i < array_size; i++)
{
cout << dim[i] << ' ';
}
Everything is working alright, but i want to change it to pointer notation. I've already tried a lot of things but when i change the array to pointer notation i get a weird output. Firstly is it even possible to change the code to pointer notation and secondly if so, how should i do it? I would be grateful for any advice. Thank you!