-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain4.cpp
More file actions
54 lines (43 loc) · 681 Bytes
/
main4.cpp
File metadata and controls
54 lines (43 loc) · 681 Bytes
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
//
// Created by ctsnz0060 on 27.07.2018.
//
#include <iostream>
#include <fstream>
int Read(std::istream&);
int main()
{
/*
int x1;
x1 = Read(std::cin);
if (x1 == -1)
{
std::cout << "fail" << std::endl;
}
else
{
std::cout << x1 << std::endl;
}
*/
int x2;
std::string path("../test.txt");
std::ifstream in(path);
x2 = Read(in);
if (x2 == -1)
{
std::cout << "fail" << std::endl;
}
else
{
std::cout << x2 << std::endl;
}
return 0;
}
int Read(std::istream& input)
{
int x1;
input >> x1;
if (input.good())
return x1;
else
return -1;
}