#include <iostream>
#include <new>
using namespace std;

int main ()
{
  int i,n;
  int * p;
  cout << "How many numbers would you like to type? ";
  cin >> i;
  p= new (nothrow) int[i];
  if (p == 0)
    cout << "Error: memory could not be allocated";
  else
  {
    for (n=0; n<i; n++)
    {
      cout << "Enter number: ";
      cin >> p[n];
    }
    cout << "You have entered: ";
    for (n=0; n<i; n++)
      cout << p[n] << ", ";
    delete[] p;
  }
  return 0;

for example i want 3 numbers, say the numbers you enter are 1,2,3, it'l will come up ive entered 1,2,3 in that order. i want to know how you reverse that so that it reads what you've typed in,(dynamic memory etc.) then reverses that order. tried about with it but cant get it going? any takers?

Re: reversing the output c++ 80 80

Either you insert the numbers in the array in reverse order and print the array normally

 for (n=i-1; n!=-1; n--)
    {
      cout << "Enter number: ";
      cin >> p[n];
    }

or normally insert items in the array, and print them in reverse order

for (n=i-1; n!=-1; n--)
      cout << p[n] << ", ";
Re: reversing the output c++ 80 80

did that second method there and its working si far except for one instance, when i do 1,2,3 it comes up 0,3,2,1?

Re: reversing the output c++ 80 80

Yeah, well initially was

 for (n=i; n!=-1; n--)

but I edited in

 for (n=i-1; n!=-1; n--)

Was a little bit quick on typewriting, forgot that -1 near the i. Try it now, it will definately work.

Re: reversing the output c++ 80 80

lifesaver lucaci, as you can probably tell, im a beginner,trying to learn all the time.lol
Thanks again

Re: reversing the output c++ 80 80

Glad I could help. Also, don't forget to mark this thread as solved, since the matter at hand is no longer the problem. If you do have further questions, for each question start a new thread explaining the situation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.