#include #include #include #include using namespace std; int main() { ifstream fin; fin.open("/home/www/dics/web2.txt"); if (fin.fail()) { cerr << "could not open dictionary file\n"; exit(1); } vector positions; int pos = 0; while (true) { string line; getline(fin, line); if (fin.fail()) break; positions.push_back(pos); cout << "pushing " << pos << "\n"; pos += line.length() + 1; } fin.clear(); while (true) { cout << "line number: "; int n; cin >> n; cout << "positions[ " << n << "] = " << positions[n] << "\n"; fin.seekg(positions[n]); string line; getline(fin, line); cout << line << "\n"; } fin.close(); }