I am just learning pointers and have a question about how to display 
from an array.  I have created a program that has a preset array 
loaded with the word 'champlain'.  I then use pointers to display the 
name in reverse order.  My question is, how can I take in a string or 
any size into an array and display that out using pointers?  I don't 
need code, just ideas to help me learn a clear way to problem solve.  
This is my program with a set string preloaded into the array.

        const int num = 9;
        string name[num] = {"c","h","a","m","p","l","a","i","n"};
        string *ptr;

                ptr = name;

                cout << "The string is ";

                for(int count = 0; count < num; count++)
                {
                        cout << *(ptr + count);
                }
                        cout << endl;
                        cout << "The string displayed backward is ";
                
                for(int count = 8; count >= 0; count--)
                {
                        cout << *(ptr + count);
                }
                cout << endl;

Thanks,
Jon

Reply via email to