Advertisement
dxvmxnd

Untitled

Dec 11th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. set<string> createPossibleVocabulary(bool& englishLanguage) {
  2.  
  3. string path;
  4. set<string> vocabulary = {};
  5.  
  6. if (englishLanguage) {
  7. path = "..\\..\\englishvocabulary.txt";
  8. }
  9. else {
  10. path = "..\\..\\russianvocabulary.txt";
  11. }
  12.  
  13. string word = "";
  14.  
  15.  
  16. ifstream fin(path);
  17. if (!fin.is_open()) {
  18. printf("Какая-то ошибка с файлом.");
  19. }
  20. else {
  21. while (fin >> word) {
  22. vocabulary.insert({ word });
  23. }
  24. }
  25. fin.close();
  26.  
  27. return vocabulary;
  28.  
  29. }
  30.  
  31. void addNewWord(string line, set<string>& vocabulary, bool& englishLanguage) {
  32.  
  33. string path;
  34. string word = "";
  35.  
  36. if (englishLanguage) {
  37. path = "..\\..\\englishvocabulary.txt";
  38. }
  39. else {
  40. path = "..\\..\\russianvocabulary.txt";
  41. }
  42.  
  43. ofstream fout(path, fstream::app);
  44. fout << "\n" << line;
  45. fout.close();
  46.  
  47. vocabulary.insert({ line });
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement