Hey everyone, This program has been bothering me. It basically takesa file and c
ID: 3617085 • Letter: H
Question
Hey everyone, This program has been bothering me. It basically takesa file and converts it to html. I am posting the questionbelow. Write a program that reads in a C++ source file and converts all < symbolsto < and all > symbols to > . Also add the tag <PRE> to the beginningof the file and </PRE> to the end of the file. This tag preserves whitespaceand formatting in the HTML document. Your program should output the HTMLfile 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 textfile with the following contents:<PRE>#include <iostream>int main(){int x=4;if (x < 3) x++;cout << x << endl;}</PRE> I am also posting my source code below, please help me out.
#include <iostream>#include <fstream>#include <cstring>#include <string>using namespace std;int main(){const int size=51;char fileName[size]; // Input file to convertchar outputname[size]; // Output file with .html on the endchar c;int i;ifstream inStream;ofstream outStream;cout << "Enter filename to convert: " << endl;cin >> fileName;inStream.open(fileName,ios::in);outStream.open("outfile.html");inStream.close();outStream.close();cout << "Conversion done. Results in file " << outputname << endl;system("pause");return 0;} This program has been bothering me. It basically takesa file and converts it to html. I am posting the questionbelow. Write a program that reads in a C++ source file and converts all < symbolsto < and all > symbols to > . Also add the tag <PRE> to the beginningof the file and </PRE> to the end of the file. This tag preserves whitespaceand formatting in the HTML document. Your program should output the HTMLfile 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 textfile with the following contents:<PRE>#include <iostream>int main(){int x=4;if (x < 3) x++;cout << x << endl;}</PRE> I am also posting my source code below, please help me out.
#include <iostream>#include <fstream>#include <cstring>#include <string>using namespace std;int main(){const int size=51;char fileName[size]; // Input file to convertchar outputname[size]; // Output file with .html on the endchar c;int i;ifstream inStream;ofstream outStream;cout << "Enter filename to convert: " << endl;cin >> fileName;inStream.open(fileName,ios::in);outStream.open("outfile.html");inStream.close();outStream.close();cout << "Conversion done. Results in file " << outputname << endl;system("pause");return 0;}