#pragma once #include class StringContainer { public: StringContainer(std::string &fileName, size_t count, size_t length) { fopen_s(&file_, fileName.c_str(), "r"); count_ = count; length_ = length; } bool find(std::string &string) { return find(string, 0, count_); } bool find(std::string &string, size_t from, size_t to) { size_t now = (from + to) / 2; // WFT '\n' use 2 byte?! fseek(file_, now * (length_ + 2) * sizeof(char) , SEEK_SET); size_t index; char symbol; for (index = 0; index < length_; ++index) { fscanf_s(file_, "%c", &symbol, 1); if (string[index] != symbol) break; } if (index == length_) return true; if (now == from) return false; if (string[index] > symbol) { return find(string, now, to); } else { return find(string, from, now); } } private: FILE* file_; // Файловый дискриптор size_t count_; // Кол-во строк size_t length_; // Длина строки };