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

Write a C++ program which produces an HTML file from a text file. The HTML file

ID: 673448 • Letter: W

Question

Write a C++ program which produces an HTML file from a text file.

The HTML file should contain the text file's content, surrounded by appropriate HTML tags:

<html>

<body>

....text file contents here...

</body>

</html>

In addition, the text copied from the text file should have two line break tags between sentences:

This is the first sentence.

<br/><br/>

This is the second sentence.

For simplicity, assume a sentence is defined as a line ending with a period ('.').

Use the text file Gettysburg.txt as input and create the file Gettysburg.html as output.

You may want to echo text read from the input file to the console.

Gettysburg.txt file information:

Explanation / Answer

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream inputFile;
ofstream outputFile;
char c;
inputFile.open("Gettysburg.txt");
outputFile.open("Gettysburg.html");
outputFile << "<html> <body> ";
while(!inputFile.eof())
{
inputFile.get(c);
outputFile << c;
if(c == '.')
outputFile <<" <br/><br/> ";
}
outputFile << "</body> </html>";
}

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