-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (61 loc) · 1.29 KB
/
Copy pathmain.cpp
File metadata and controls
64 lines (61 loc) · 1.29 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "func.h"
#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{
setlocale(LC_ALL, "Rus");
try
{
ifstream fin;
long file_size;
int j = 0, c = 0;
string s = " ", input, l;
stringstream sstreambuf; //ñòðîêîâûé ïîòîê
fin.open("input.txt", ios::in);
if (!fin)
{
exception ex("\nÍåò ôàéëà\n");
throw ex;
}
if (fin.peek() == -1)
{
exception ex("\nÍåò äàííûõ\n");
throw ex;
}
while (!fin.eof()) {//ñ÷èòûâàåì ïî ïðåäëîæåíèþ
s = "";
c++;
getline(fin, input);
if (input.length() == 0)
continue;
while (input.length() != 0)
{
j = find_first_of(input);
if (j == -1)
{
cout << "Â " << c << " ñòðîêå\n";
exception ex("\nÎøèáêà: íåò çíàêîâ êîíöà ïðåäëîæåíèÿ");
throw ex;
}
s = copy(input, j + 1);
string temp, tmp = sstreambuf.str(); //âîçâðàùàåòñÿ êîïèÿ ñòðîêè, êîòîðóþ õðàíèò ïîòîêîâûé îáúåêò
sstreambuf.str(""); //àðãóìåíò áóäåò êîïèðîâàòüñÿ â ïîòîêîâûé îáúåêò
sstreambuf << s << tmp;
input = my_erase(input, j + 1);//óäàëÿåì îáðàáîòàííîå ïðåäëîæåíèå
}
}
getline(sstreambuf, l);
cout << l;
fin.close();//çàêðûâàåì ôàéë
}
catch (exception& ex)
{
cout << ex.what() << endl << endl;
}
system("pause");
return 0;
}