Reverse a string - c ++ program, C/C++ Programming

Reverse a string - C ++ program:

Write a program in c to reverse a string.

int main()

{

    Stack theStack;

    String reverse("reverse");

 

    cout << "\nEnter some strings.  Reverse will collect the strings\n";

    cout << "for you until you enter the string \"reverse\".  Reverse\n";

    cout << "will then print out the strings you have entered, but in\n";

    cout << "reverse order.  Begin entering strings now.\n";

 

    for(;;)

        {

        char inputString[255];

        cin >> inputString;

        String& newString = *( new String( inputString ) );

        if( newString != reverse )

            {

            theStack.push( newString );

            }

        else

            {

            break;

            }

        }

 

    cout << "\nThe strings you entered (if any) are:\n";

    while( !(theStack.isEmpty()) )

        {

        Object& oldString = theStack.pop();

        cout << oldString << "\n";

        delete &oldString;

        }

    return 0;

}

Posted Date: 10/19/2012 3:05:23 AM | Location : United States







Related Discussions:- Reverse a string - c ++ program, Assignment Help, Ask Question on Reverse a string - c ++ program, Get Answer, Expert's Help, Reverse a string - c ++ program Discussions

Write discussion on Reverse a string - c ++ program
Your posts are moderated
Related Questions
Stack operations - C++: Write a program to define basic stack operations in c++. int Stack::push(int elem) {    int m = getmax();    if (top    {       put_

Why are all header files not declared in every C program? - Declaring all header files in each program would result in increase in overall file size and load of the program. It

I am having trouble declaring a variable and returning a value from my function.

#questionAt a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets

Define the Stream Oriented Data Files? There are two dissimilar types of data files called stream-oriented (or standard) data files and system-oriented (or low-level) data file

program that convert take decimal digit and convert it to binart digit

A container class is a class which is used to hold objects in external storage and memory. A container class work as a generic holder. A container class contains a predefined behav

What is memory allocation? Memory Allocation : It is the method of allocating memory storage to program in such that the program can be run.


A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome