Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- int keywords = 0;
- int operators = 0;
- string line;
- ifstream myfile ("Example.java");// open file
- if (myfile.is_open())
- {
- while ( myfile.good() )//if open read
- {
- getline (myfile,line);//read per line, assign to string nga line
- //cout << line << endl;
- istringstream iss(line);
- do// spliting lines
- {
- string sub;
- iss >> sub;
- cout << "Substring: " << sub << endl;
- //compare ang sub to keywords and operators
- //if(sub == "int" || sub == "double" || sub == "bool" .......)
- // keydword++; <= increment
- //if(sub == "+" || sub == "-" || sub == "*" .......)
- //operator++; <= increment
- } while (iss);
- }
- myfile.close();
- }
- else cout << "Unable to open file";
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment