Guest User

Untitled

a guest
Apr 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <fstream>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int keywords = 0;
  12. int operators = 0;
  13.  
  14. string line;
  15. ifstream myfile ("Example.java");// open file
  16. if (myfile.is_open())
  17. {
  18. while ( myfile.good() )//if open read
  19. {
  20. getline (myfile,line);//read per line, assign to string nga line
  21. //cout << line << endl;
  22.  
  23. istringstream iss(line);
  24.  
  25. do// spliting lines
  26. {
  27. string sub;
  28. iss >> sub;
  29. cout << "Substring: " << sub << endl;
  30. //compare ang sub to keywords and operators
  31. //if(sub == "int" || sub == "double" || sub == "bool" .......)
  32. // keydword++; <= increment
  33. //if(sub == "+" || sub == "-" || sub == "*" .......)
  34. //operator++; <= increment
  35. } while (iss);
  36.  
  37. }
  38. myfile.close();
  39. }
  40.  
  41. else cout << "Unable to open file";
  42.  
  43.  
  44.  
  45. system("PAUSE");
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment