Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- string kappa;
- vector <string>digits;
- fstream f("C:\\Users\\Rihards\\Desktop\\compiler\\comp.txt", ios::in);
- // ios::in File open for reading
- string temp;
- //if (kappa[i]=='\0');
- int linecount = 0;
- do
- {
- std::getline(f, kappa);
- linecount++;
- int i = 0;
- while (kappa[i] == ' ')
- {
- i++;
- }
- if (isalpha(kappa[i]))
- {
- i++;
- //тут я ловлю кейворды
- }
- else if (isdigit(kappa[i]))
- {
- do {
- temp += kappa[i];
- i++;
- } while (isdigit(kappa[i]));
- digits.push_back(temp);
- //сюда записываю массив
- }
- else //массив делимторов
- {
- i++;
- //linecount для того, чтобы ругаться на строку i нужен для позиции в строке
- //cout << "we have a problem with line" << linecount;
- //cout << "(" << i << ")" << endl;
- }
- temp.clear();
- }
- while (!f.eof());
- for (int i = 0; i < digits.size(); i++) {
- cout << digits[i] << endl;
- }
- f.close(); //закрывать файловую переменную. файл нам еще пригодится!
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement