Solved

# Need help with pointer output using array and pointer notation

Posted on 2007-11-14

Ok this is a continuation question.. I am using pointer notation with the output being in a function and the input being in the main body. Problem is it compiles works except the output is not the numbers reversed it is a weird output.

Here is my code:

#include <iostream>

using namespace std;

void arrayRev();

const int SIZE = 5;

int main()

{

int numbers[SIZE];

int* p_numbers;

int counter;

p_numbers = numbers;

cout << "Enter five integers: ";

for (counter = 0; counter < SIZE; counter++)

{

cin >> numbers[counter];

cout << "Enter five integers: ";

}

cout << endl;

arrayRev();

return 0;

}

void arrayRev()

{

int numbers[SIZE];

int* p_numbers;

int counter;

p_numbers = numbers;

cout << "The numbers in reverse are: ";

for (counter = 4; counter >= 0; counter--)

cout << *(p_numbers+counter) << " ";

cout << endl;

}