Q:

c++ displaying sentences in reverse order using pointers

i'm trying to build a program that takes short sentences from the user and display them in reverse order. unfortunately, I just began c++ I need to know to do that.
for example: if user entered input:
I like the red color
blue is also nice
and green is lovely
but I don't like orange

output:
but I don't like orange
and green is lovely
blue is also nice
I like the red color

Thanks in advance!
#include<iostream>
#include<string>
using namespace std;

const int SIZE= 500;

int main()
{

   const int SIZE = 500;
   char mystring[SIZE];
int i;
for(i=0; i<SIZE; i++)
{

    cout<<"Enter a string: ";
    cin.getline(mystring, SIZE);
    } while (mystring != 0);

       char * reverse= new char[strlen(mystring) + 1];
        char *p1 = mystring+ strlen(mystring);
        char *p2 = reverse;

        while(p1 != mystring)
        {
        p1--;
        *p2= *p1;
        p2++;
    }

    *p2 = '\0';
    cout << reverse<<endl;

   system("PAUSE");
   return 0;
}

A:

A considerable way you're intended to approach this is the following algorithm:

Load the file into a buffer, terminating it with a null char.
Position a pointer p to the location of the last buffer slot.
While p is not pointing to the start of the buffer do the following:

If the character is a newline ('\n') then 

Send the string past the newline (p+1) to stdout.
Overwrite the newline pointed to by p with a null char.

Decrement p back one char position. 

After the above loop is finished there is one line remaining: the first one. send it to stdout and you're done.

Or so I am led to believe. Important things to consider are the following:

Does the algorithm work with an empty file?
Does the algorithm work with a file containing ONLY newlines?
Does the algorithm work with a multi-line file WITH NO trailing newline?
Does the algorithm work with a single line file WITH NO trailing newline?
Does the algorithm work with a multi-line file WITH trailing newline?
Does the algorithm work with a single line file WITH trailing newline?

That being said, here is a potential candidate:
#include <iostream>
#include <fstream>
#include <iterator>
#include <vector>
using namespace std;

int main(int argc, char *argv[])
{
    // assume the file to reverse-print is the first
    //  command-line parameter. if we don't have one
    //  we need to leave now.
    if (argc < 2)
        return EXIT_FAILURE;

    // will hold our file data
    std::vector<char> data;

    // open file, turning off white-space skipping
    ifstream inf(argv[1]);
    inf.seekg(0, inf.end);
    size_t len = inf.tellg();
    inf.seekg(0, inf.beg);

    // resize buffer to hold (len+1) chars
    data.resize(len+1);
    inf.read(&data[0], len);
    data[len] = 0; // terminator

    // walk the buffer backwards. at each newline, send
    //  everything *past* it to stdout, then overwrite the
    //  newline char with a nullchar (0), and continue on.
    char *start = &data[0];
    char *p = start + (data.size()-1);
    for (;p != start; --p)
    {
        if (*p == '\n')
        {
            if (*(p+1))
                cout << (p+1) << endl;
            *p = 0;
        }
    }

    // last line (the first line)
    cout << p << endl;

    return EXIT_SUCCESS;
}

Input
I like the red color
blue is also nice
and green is lovely
but I don't like orange

Output
but I don't like orange
and green is lovely
blue is also nice
I like the red color

A Considerably Simpler Approach
There are much simpler ways to do this, and I'll explain each step in comment along the way. Chance are you can't use something like this, but it is important you understand what is available to you when you can:
#include <iostream>
#include <fstream>
#include <iterator>
#include <vector>
using namespace std;

int main(int argc, char *argv[])
{
    // assume the file to reverse-print is the first
    //  command-line parameter. if we don't have one
    //  we need to leave now.
    if (argc < 2)
        return EXIT_FAILURE;

    // collection that will hold our lines of text
    vector<string> lines;

    // read lines one at a time until none are returned
    //  pushing each line in to our vector.
    ifstream inf(argv[1]);
    string line;
    while (getline(inf, line))
        lines.push_back(line);
    inf.close();

    // a LOT happens in the next single line of code, and
    //  I will try to describe each step along the way.
    //
    // we use std::copy() to copy all "items" from
    //   a beginning and ending iterator pair. the
    //   target of the copy is another iterator.
    //
    //  our target iterator for our formatted ouput
    //   is a special iterator class designed to
    //   perform an output-stream insertion operation
    //   (thats the << operator) to the stream it is
    //   constructed with (in our case cout) using each
    //   item we give it from our copy-iteration. to use
    //   this class the "copied" item must support the
    //   traditional insertion operator <<, which of
    //   course, std::string does. after each item is
    //   written, the provided suffix (in our case \n)
    //   is written as well. without this all the lines
    //   would be ganged together.
    //
    //  lastly, to glue this together (and the whole
    //   reason we're here), we use a pair of special
    //   iterators designed to  work just like the regular
    //   begin() and end() iterators you're familiar with,
    //   when traversing forward in a sequence, but these
    //   ones, rbegin() and rend(), move from the last
    //   item in the sequence to the first item, which is
    //   *exactly* what we need.

    copy(lines.rbegin(), lines.rend(), 
         ostream_iterator<string>(cout, "\n"));

    // and thats it.
    return EXIT_SUCCESS;
}

Input
I like the red color
blue is also nice
and green is lovely
but I don't like orange

Output
but I don't like orange
and green is lovely
blue is also nice
I like the red color

UPDATE: Incorporating User Input
An example of incorporating user input for the second version would be:
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;

int main(int argc, char *argv[])
{
    // collection that will hold our lines of text
    vector<string> lines;
    do
    {   // prompt the user
        cout << "Sentance (<enter> to exit): ";
        string line;
        if (!getline(cin, line) || line.empty())
            break;
        lines.push_back(line);
    } while (true);

    // send back to output using reverse iterators
    //  to switch line order.
    copy(lines.rbegin(), lines.rend(),
         ostream_iterator<string>(cout, "\n"));

    return EXIT_SUCCESS;
}

