Advertisement
skb50bd

CodeGenerator

Aug 30th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     ofstream outfile;
  9.     string line;
  10.  
  11.     cout << "Enter Message: ";
  12.     getline(cin, line);
  13.  
  14.     outfile.open("Code.cpp", ios::app);
  15.  
  16.     outfile << "#include <iostream>" << endl;
  17.     outfile << "using namespace std;" << endl << endl;
  18.     outfile << "int main() {" << endl;
  19.     outfile << "\tchar msg[] = {";
  20.  
  21.     for(int i = 0; line[i]; i++)
  22.         outfile << int(line[i]) << ", ";
  23.     outfile << 0;
  24.  
  25.     outfile << "};" << endl;
  26.     outfile << "\tcout << msg << endl;" << endl;
  27.     outfile << "\treturn 0;" << endl;
  28.     outfile << "\}" << endl;
  29.  
  30.     outfile.close();
  31.  
  32.     cout << "Source File Created Successfully" << endl;
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement