HTML files use tags enclosed in angle brackets to denote formatting instructions. For example, <B> indicates bold and <I> indicates italic. If a web browser is displaying an HTML document that contain < or >, it may mistake these symbols for tags. This is a common problem with C++ files, which contain many <'s and >'s. For example, the line "#include <iostream>" may result in the browser interpreting <iostream> as a tag.
To avoid this problem, HTML uses special symbols to denote < and >. The < symbol is created with the string < while the > symbol is created with the string >.
Write a program that reads in a C++ source file and converts all < symbols to < and all > symbols to >. Also add the tag <PRE> to the begining of the file and </PRE> to the end of the file. This tag preserves whitespace and formatting in the HTML document. Your program should output the HTML file to disk.
As an example, given the following input file;
#include <iostream>
int main()
{
int x = 4;
if (x < 3) x++;
cout<< x << endl;
}
the program should produce a text file with the following contents:
<PRE>
#include <iostream>
int main()
{
int x = 4;
if (x < 3) x++;
cout<< x << endl;
}
</PRE>
you can test your output file by opening it with a web browser. The contents should appear identical to the original source code.