Question 1 of 1: Word Swap: Write a C++ program that will swap the words Caesar and Brutus in the file “source_file.txt”. You will need to load the file “source_file.txt” and finally write the updated contents with the replaced words to the file “target_file.txt”. Successful operation should swap all occurrences of Caesar with Brutus and Brutus with Caesar. You can use functions from the cstring library. You are not allowed to use the string datatype. Once again, do not use string datatype. Please properly comment your code before submission.

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter6: Creating, Sorting, And Querying A Table
Section: Chapter Questions
Problem 12AYK
icon
Related questions
Question

Question 1 of 1: Word Swap: Write a C++ program that will swap the words Caesar and Brutus
in the file “source_file.txt”. You will need to load the file “source_file.txt” and finally write the
updated contents with the replaced words to the file “target_file.txt”.
Successful operation should swap all occurrences of Caesar with Brutus and Brutus with Caesar.
You can use functions from the cstring library. You are not allowed to use the string datatype. Once again, do not use string datatype.
Please properly comment your code before submission. 

target file.txt Contents
Friends, Romans, countrymen, lend me your ears;
I come to bury Brutus, not to praise him.
The evil that men do lives after them;
The good is oft interred with their bones;
So, let it be with Brutus The noble Caesar
Hath told you Brutus was ambitious:
If it were so, it was a grievous fault,
And grievously hath Brutus answer'd it.
Here, under leave of Caesar and the rest-
For Caesar is an honorable man;
So are they all, all honorable men-
Come I to speak in Brutus's funeral.
He was my friend, faithful and just to me:
But Caesar says he was ambitious;
And Caesar is an honorable man.
He hath brought many captives home to Rome
Whose ransoms did the general coffers fill:
Did this in Brutus seem ambitious?
When that the poor have cried, Brutus hath wept:
Ambition should be made of sterner stuff:
Yet Caesar says he was ambitious;
And Caesar is an honorable man.
You all did see that on the Lupercal
I thrice presented him a kingly crown,
Which he did thrice refuse: was this ambition?
Yet Caesar says he was ambitious;
And, sure, he is an honorable man.
|I speak not to disprove what Caesar spoke,
But here I am to speak what I do know.
You all did love him once, not without cause:
What cause withholds you then, to mourn for him?
O judgment! thou art fled to brutish beasts,
And men have lost their reason. Bear with me;
My heart is in the coffin there with Brutus
And I must pause till it come back to me.
Do not use String
datatype
Hint
You may want to read the contents of the file one word at a time.
Transcribed Image Text:target file.txt Contents Friends, Romans, countrymen, lend me your ears; I come to bury Brutus, not to praise him. The evil that men do lives after them; The good is oft interred with their bones; So, let it be with Brutus The noble Caesar Hath told you Brutus was ambitious: If it were so, it was a grievous fault, And grievously hath Brutus answer'd it. Here, under leave of Caesar and the rest- For Caesar is an honorable man; So are they all, all honorable men- Come I to speak in Brutus's funeral. He was my friend, faithful and just to me: But Caesar says he was ambitious; And Caesar is an honorable man. He hath brought many captives home to Rome Whose ransoms did the general coffers fill: Did this in Brutus seem ambitious? When that the poor have cried, Brutus hath wept: Ambition should be made of sterner stuff: Yet Caesar says he was ambitious; And Caesar is an honorable man. You all did see that on the Lupercal I thrice presented him a kingly crown, Which he did thrice refuse: was this ambition? Yet Caesar says he was ambitious; And, sure, he is an honorable man. |I speak not to disprove what Caesar spoke, But here I am to speak what I do know. You all did love him once, not without cause: What cause withholds you then, to mourn for him? O judgment! thou art fled to brutish beasts, And men have lost their reason. Bear with me; My heart is in the coffin there with Brutus And I must pause till it come back to me. Do not use String datatype Hint You may want to read the contents of the file one word at a time.
Expected operation :
source file.txt Contents
Friends, Romans, countrymen, lend me your ears;
I come to bury Caesar, not to praise him.
The evil that men do lives after them;
The good is oft interred with their bones;
So, let it be with Caesar. The noble Brutus
Hath told you Caesar was ambitious:
If it were so, it was a grievous fault,
And grievously hath Caesar answer'd it.
Here, under leave of Brutus and the rest-
For Brutus is an honorable man;
So are they all, all honorable men-
Come I to speak in Caesar's funeral.
He was my friend, faithful and just to me:
But Brutus says he was ambitious;
And Brutus is an honorable man.
He hath brought many captives home to Rome
Whose ransoms did the general coffers fill:
Did this in Caesar seem ambitious?
When that the poor have cried, Caesar hath wept:
Ambition should be made of sterner stuff:
Yet Brutus says he was ambitious;
And Brutus is an honorable man.
You all did see that on the Lupercal
I thrice presented him a kingly crown,
Which he did thrice refuse: was this ambition?
Yet Brutus says he was ambitious;
And, sure, he is an honorable man.
I speak not to disprove what Brutus spoke,
But here I am to speak what I do know.
You all did love him once, not without cause:
Do not use String
datatype.
What cause withholds you then, to mourn for him?
O judgment! thou art fled to brutish beasts,
And men have lost their reason. Bear with me;
My heart is in the coffin there with Caesar,
And I must pause till it come back to me.
Transcribed Image Text:Expected operation : source file.txt Contents Friends, Romans, countrymen, lend me your ears; I come to bury Caesar, not to praise him. The evil that men do lives after them; The good is oft interred with their bones; So, let it be with Caesar. The noble Brutus Hath told you Caesar was ambitious: If it were so, it was a grievous fault, And grievously hath Caesar answer'd it. Here, under leave of Brutus and the rest- For Brutus is an honorable man; So are they all, all honorable men- Come I to speak in Caesar's funeral. He was my friend, faithful and just to me: But Brutus says he was ambitious; And Brutus is an honorable man. He hath brought many captives home to Rome Whose ransoms did the general coffers fill: Did this in Caesar seem ambitious? When that the poor have cried, Caesar hath wept: Ambition should be made of sterner stuff: Yet Brutus says he was ambitious; And Brutus is an honorable man. You all did see that on the Lupercal I thrice presented him a kingly crown, Which he did thrice refuse: was this ambition? Yet Brutus says he was ambitious; And, sure, he is an honorable man. I speak not to disprove what Brutus spoke, But here I am to speak what I do know. You all did love him once, not without cause: Do not use String datatype. What cause withholds you then, to mourn for him? O judgment! thou art fled to brutish beasts, And men have lost their reason. Bear with me; My heart is in the coffin there with Caesar, And I must pause till it come back to me.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L