-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (57 loc) · 1.24 KB
/
main.cpp
File metadata and controls
76 lines (57 loc) · 1.24 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
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <stdexcept>
#include "variable.h"
#include "calculator.h"
#include <fstream>
void f();
void f();
int main()
try
{
define_name("pi", 3.141592653589793);
define_name("e", 2.718281828459045);
std::string filename = "test.txt";
std::ifstream input_file(filename);
if (input_file) {
std::streambuf* original_cin = std::cin.rdbuf();
std::cin.rdbuf(input_file.rdbuf());
calculate();
std::cin.rdbuf(original_cin);
std::cout << " End of file " << std::endl;
return 0;
}
else {
std::cerr << "Test file '" << filename << "' not found. Starting interactive mode." << std::endl;
}
return 0;
}
catch (std::exception& e)
{
std::cerr << "exception: " << e.what() << std::endl;
return 1;
}
catch (...)
{
std::cerr << "Oops, unknown exception" << std::endl;
return 2;
}
/*
int main ()
try
{
define_name ("pi", 3.141592653589793);
define_name ("e", 2.718281828459045);
calculate();
return 0;
}
catch (std::exception& e)
{
std::cerr << "exception: " << e.what() << std::endl;
return 1;
}
catch (...)
{
std::cerr << "Oops, unknown exception" << std::endl;
return 2;
}
*/