Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. int main(int argc, char* argv[])
  2. {
  3.         string path = "C:\\log1.txt";
  4.         ifstream file;
  5.         file.open(path);
  6.         assert(file);
  7.         ofstream file2("output.txt");
  8.         string line;
  9.         string total;
  10.         for(int i=0;file.good();i++)
  11.         {
  12.                 getline(file,line);
  13.                 total +=line;
  14.                 regex rx1(";");
  15.                 line = regex_replace(line, rx1, "__SEMICOLON__");
  16.                 regex rx2("private|public|class|include|namespace|string|iostream");
  17.                 line = regex_replace(line, rx2, "_C++_KEYWORD__");
  18.                 regex rx3("{|(");
  19.                 line = regex_replace(line, rx3, "__OPENING_BRACE__");
  20.                 regex rx4("}|)");
  21.                 line = regex_replace(line, rx4, "__CLOSING_BRACE__");
  22.                 file2<<i<<" "<<line<<endl;
  23.         }
  24.         int numWords=0;
  25.         for(int i=0;i<total.length();i++)
  26.         {
  27.                 if(total[i]==' ')
  28.                         numWords++;
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement