Created
April 2, 2015 17:25
-
-
Save justinrixx/7db92ec2ac5b68dcdd27 to your computer and use it in GitHub Desktop.
Given a text file, writes a file containing a cout statement which produces identical output through the output stream as reading the file in a text editor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <fstream> | |
using namespace std; | |
int main(int argc, char ** argv) | |
{ | |
if (argc != 3) | |
{ | |
cout << "Usage: " << argv[0] << " inFilename outFilename" << endl; | |
return 0; | |
} | |
else | |
{ | |
string s; | |
ifstream fin(argv[1]); | |
ofstream fout(argv[2]); | |
getline(fin, s); | |
fout << "cout << \"" << s << "\" << endl"; | |
while (getline(fin, s)) | |
fout << endl << "<< \"" << s << "\" << endl"; | |
fout << " << endl;"; | |
fin.close(); | |
fout.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment