CS1440 - Due Nov. 10, 2000
Write a C++ code to convert an input file into a simple Hyper Text Markup Language (HTML) file. In order to do this, you will read an input file, myfile, from the beginning to the end and create an output file, myfile.html by following the instructions given below. You need to use the get function to read the input file character-by-character.
1) Every time you run your program, the first thing you will do is to write the following lines at the beginning of the output file:
This is my C++ html converter <br>
2) From this point on, you will write the contents of the input file exactly the way it is. However, you need to do something for the end of each line. Every time you get to the end of a line (\n), write <br> in the output file and move to the next line of the input and repeat the same thing. In html <br> stands for break line.
For example suppose your input file has the following two lines:
Line 1 on the input file: I have a black cat.
Line 2 of the input file: I have a white dog.
As you can see at the end of the first line I have a '\n'. So once I see that, I will write <br> in the output file. Thus, my output file will look like this:
I have a black cat. <br>
I have a white dog.
3) After reading the input file and copying it completely into the output file, you will write the following two lines at the end of the output file.
This file is an html file and if you have done everything correctly, you can open it using a web browser like Netscape or Internet Explorer.
Hi my name is David.
This is my web page.
This is my web page <br>
Hi my is David. <br>
This is my web page
How to create the input file myfile. Use pico and create a file that includes the following information at the top in the same format.
First Name :
Write five lines about yourself. Anything you wish to include but make sure it is written on 5 lines.
Your program should include the following functions:
Get_files It assign the myfile and myfile.html names to two arrays and will return
the arrays to the main program.
Test_files Test the input and output files and create the streams after they are validated successfully.
Header() This function will write the first four lines shown in part (1) onto the output file.
Footer() This function will write the last two lines onto the output file.
Copy_text This file copy the contents of the input file, myfile, onto the output file line by line, and consider the given instruction for the new line as it write each line.