blob: 2e07a0c6c72dd1de19e942731a939a23c6e4ed42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <fstream>
#include <iostream>
int main() {
int m, n;
std::cin >> m >> n;
char fileName[1024];
std::cin.ignore();
std::cin.getline(fileName, 1024);
std::ifstream file(fileName);
if (!file.is_open()) {
std::cout << "Couldn't open file!" << std::endl;
return 1;
}
unsigned lineIndex = 1;
while (!file.eof()) {
if (file.peek() == '\n') {
lineIndex = 1;
file.get();
std::cout << std::endl;
continue;
}
if (m <= lineIndex && lineIndex <= n) {
std::cout << (char)file.peek();
}
lineIndex++;
file.get();
}
std::cout << std::endl;
file.close();
}
|