Advertisement
golim22

Untitled

Nov 22nd, 2017
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.  
  11. string kappa;
  12. vector <string>digits;
  13. fstream f("C:\\Users\\Rihards\\Desktop\\compiler\\comp.txt", ios::in);
  14. // ios::in File open for reading
  15.  
  16. string temp;
  17.  
  18. //if (kappa[i]=='\0');
  19. int linecount = 0;
  20. do
  21. {
  22.  
  23. std::getline(f, kappa);
  24. linecount++;
  25. int i = 0;
  26.  
  27. while (kappa[i] == ' ')
  28. {
  29. i++;
  30. }
  31.  
  32. if (isalpha(kappa[i]))
  33. {
  34. i++;
  35. //тут я ловлю кейворды
  36. }
  37. else if (isdigit(kappa[i]))
  38. {
  39. do {
  40. temp += kappa[i];
  41. i++;
  42. } while (isdigit(kappa[i]));
  43. digits.push_back(temp);
  44.  
  45.  
  46. //сюда записываю массив
  47. }
  48.  
  49. else //массив делимторов
  50. {
  51. i++;
  52. //linecount для того, чтобы ругаться на строку i нужен для позиции в строке
  53. //cout << "we have a problem with line" << linecount;
  54. //cout << "(" << i << ")" << endl;
  55. }
  56.  
  57. temp.clear();
  58.  
  59.  
  60. }
  61.  
  62. while (!f.eof());
  63.  
  64.  
  65.  
  66.  
  67. for (int i = 0; i < digits.size(); i++) {
  68. cout << digits[i] << endl;
  69. }
  70.  
  71. f.close(); //закрывать файловую переменную. файл нам еще пригодится!
  72.  
  73.  
  74.  
  75.  
  76. system("PAUSE");
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement