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
Define a structure of student class:  Write a program to define a structure of student record in C. class student { char name[20]; int roll_no; int marks[2];

w.a.p to find outWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Aim: To implement program to calculate area of cube using inline function. Code: inline void area_cube(float side) {             float area;             are

how to convert a general tree into binary tree with example

You are required to give C++ implementation of following classes: 1. PropertyCategories 2. Plot 3. Flat 4. House Following is the description of all data member and member funct

Define Bitwise Left Shift and Right Shift Operators: >? The bitwise shift operators shift their first operand right (>>) or left ( // Illustration of the bitwise right shi

write a program that can accept numbers and perform all the four arithmetic operation

Design a game in c: const DODGERS = 0; const GIANTS = 1;   void main(void) {    int scoreboard [2][9];    // An array two rows by nine columns    int team, i

What happens if you write following code? string& foo()

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