fork download
  1. #include <windows.h>
  2. #include <locale>
  3. #include <string.h>
  4. #include <iostream>
  5. #include <fstream>
  6. #pragma warning(disable : 4996)
  7.  
  8. using namespace std;
  9.  
  10. void filling_file();
  11. void text_analysis();
  12.  
  13. int main()
  14. {
  15. setlocale(LC_ALL, "Russian");
  16. SetConsoleOutputCP(1251);
  17. SetConsoleCP(1251);
  18.  
  19. filling_file();
  20. text_analysis();
  21.  
  22. cout << endl; //
  23. system("pause"); //
  24. return 0;
  25. }
  26.  
  27.  
  28. void filling_file() {
  29.  
  30. const char* FName = "course_work.bin";
  31. const int key_size = 20;
  32. FILE* File;
  33.  
  34. char key_phrase[key_size]; // объявление ключевого словосочетания
  35. cout << "Enter a keyword: " << endl;
  36. cin.getline(key_phrase, key_size);
  37.  
  38. strcat(key_phrase, "*"); // добавление * в конец словосочетания
  39.  
  40. File = fopen("course_work.bin", "w+b");
  41. fwrite(&key_phrase, sizeof(key_phrase), 1, File); // запись словосочетания в бинарный файл
  42.  
  43. const int text_size = 1000;
  44.  
  45. char text[text_size] = "Хороши русские леса! Смолою пахнет сосновый бор. Под самыми тучами шумят "
  46. "зеленые вершины, метут синеву неба. Точно белые красавицы глядят в воду "
  47. "кудрявые березки. На залитых солнцем полянах раскинулись дубы. Каждым "
  48. "листочком дрожит осинка. Яркий осенний наряд у клена. Высокие стройные "
  49. "ели вытянули острые макушки. В тенистых дубравах поселились певчие птицы."
  50. "Тихие речушки протекают в лесной глуши...";
  51.  
  52. fwrite(&text, sizeof(text), 1, File); // запись текста в бинарный файл
  53.  
  54. fclose(File);
  55.  
  56. }
  57.  
  58. void text_analysis() {
  59.  
  60. FILE* File;
  61.  
  62. const int text_size = 1000;
  63. const int key_size = 20;
  64. File = fopen("course_work.bin", "r+b");
  65.  
  66. char key_phrase[key_size];
  67. char text[text_size];
  68.  
  69. fread(&key_phrase, sizeof(key_phrase), 1, File);
  70.  
  71. fread(&text, sizeof(text), 1, File);
  72.  
  73.  
  74. fclose(File);
  75. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: fatal error: windows.h: No such file or directory
 #include <windows.h>
          ^~~~~~~~~~~
compilation terminated.
stdout
Standard output is empty