Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- void readfile(char *name, string &content, int &size)
- {
- ostringstream out;
- ifstream in(name);
- size = 0;
- if(!in.good())
- throw "Error!";
- while(1)
- {
- unsigned char value = 0;
- in.read((char*) &value, 1);
- if(in.eof())
- break;
- size++;
- if(value < 32 || value > 127)
- out << "\\" << oct << setfill('0') << setw(3) << (int) value;
- else if(value == '\\')
- out << "\\\\";
- else
- out << (char) value;
- if((size % 30) == 0)
- out << "\"" << endl << "\"";
- }
- content = out.str();
- }
- int main(int argc, char **argv)
- {
- string content = "";
- int size = 0;
- readfile(argv[2], content, size);
- cout << "#include \"linkedinfile.h\"" << endl;
- cout << "LinkedInFile " << argv[1] << " = {" << size
- << ", " << endl << "\"" << content << "\"};" << endl << endl;
- cout << flush;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement