Question: // file: revString.cpp // String manipulation example // This is incomplete #include #include // for string streams #include using namespace std; // MAX_INPUT is the

 // file: revString.cpp // String manipulation example // This is incomplete

// file: revString.cpp // String manipulation example // This is incomplete

#include #include // for string streams #include using namespace std;

// MAX_INPUT is the maximum number of characters that we allow to be // read into a string object with istream::getline() static const int MAX_INPUT = 256;

int main() { char buf[MAX_INPUT]; string line = ""; string word;

cout

/* The following would be the best way to read in a line into a string * object; however, there is a bug in the code provided by MSVC that * reads an extra character (so the user would have to hit return twice. * - see http://support.microsoft.com/support/kb/articles/Q240/0/15.ASP

getline( cin, line );

*/

// The following is a workaround, use istream::getline() instead of // the function getline. cin.getline( buf, MAX_INPUT ); line = buf; // open a stream bound to the line istrstream input( line.c_str() );

while ( input >> word ) { cout

return 0; }

String exercises In the introduction, you saw some string examples that show comparison, concatenation, and substring-You should now be ready to try to use these functions. Your tasks are to do the following 3 programs (1)Write a program that will receive a line of text and reverse the order of the words so that they are printed out in LIFO order. For example: Enter a string the quick brown fox jumped over the lazy dog dog lazy the over jumped fox brown quick theThere are two simple ways to do this. One way is touse an array of strings and assign each word to an array position. You can then iterate backwards through the array and print out the words. The other way to do this is to push words onto a stack and pop them off after. Since this lab is about using templated classes, you should implement your revstring program with a stack. (2)Start with the given revstrin source file, copy it into a Labi lrev cpp file it uses string streams anistrstream object) to allow the user to enter a line and then read all the words from the line. (30Write a program that converts a word into Pig Latin. Name it Labl1Piglatin.cpp. For those of you who don't know, Pig Latin is a childhood code language that follows two simple rules: The Pig Latin translations of words that begin with a consonant are formed by moving the initial consonant to the end and appending "ay" The translations of words that begin with a vowel are formed by appending "yay" Some examples of Pig Latin translations are: hello world" becomes "ellohay orldway" "object oriented" becomes "objectyay orientedyay" If you wish you can try to extend your program to translate more than one word at a time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!