Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to write a program that will substitute one string for a new string thro

ID: 3763399 • Letter: Y

Question

You are to write a program that will substitute one string for a new string throughout the text. There will be several sets of strings for this program assignment. The input file is ‘paragraphwordsub.txt ‘. The first word on a line will be replaced by the second word listed on the same input line. There are several pairs of words for substitutes. The flag to indicate the end of the word pairs is a ‘$’. Following the ‘$’ (next line) is the text that will be used in the word substitution. You are to write the word substitution program twice. Write one program with using only C-String data and functions. Then write the same program again using only C++ String Class data and functions. Turn in the original text and the new text for each program. Note: you need to do the C-String program first.

Input file information:

Explanation / Answer

void read() { int const SIZE = 100; char s1[SIZE][SIZE]; int i = 0, k = 0, num = 0; char temp; ifstream myfile ("paragraphwordsub.txt"); myfile >> std::noskipws; if (myfile.is_open()) { myfile >> temp; while (temp!= '$') { if (temp != ' ') { s1[i][k] = temp; myfile >> temp; k++; } else { s1[i][k+1] = '/'; k=0; myfile >> temp; if (temp == ' ') { myfile >> temp; } i++; num++; } } } else cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote