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
Question : (a) (i) What is a structure member in C? What is the relationship between a structure member and the structure? (ii) How can structure variables be declared in C?

write the program to accept date and to say valid or invalid

I need Profile and optimize a C++ library for speed Project Description: Optimize and profile an existing C++ library for speed. This library uses OpenMP and OpenCV and C+

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift

A string is said to be "Beautiful"€, if it contains only non repetitive alphabets

Can I drop the [] while deleteing array of some built-in type (char, int, etc)? A: No. you can't Sometimes programmers think that the [] in the delete[] p only present so the

Write a c program to determine interchanged values between two variables?[Hint - if loop] What will be the output of the program? How many times this loop will execute? Wr

Deliverables: you are required to upload your c code in the assignment dropbox set in Moodle. You are supposed to work with Linux gcc compiler and pico editor for compiling via the

Define Static Storage Class in C Programming? The Static declarations have distinct and important uses. This allows the local variable to keep its previous value when the block

C Program for FUNCTION OF DIVIDER int gcd(int , int); void main() {           int m=0,n=0,k=0;           clrscr();           printf("ENTER THE FIRST DIGIT: ");