-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathcerr.cpp
65 lines (51 loc) · 1.07 KB
/
cerr.cpp
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
// Use cerr to debug
#include <iostream>
#define ENABLE_DEBUG // comment out to disable debugging
int getUserInput()
{
#ifdef ENABLE_DEBUG
std::cerr << "getUserInput() called\n";
#endif
std::cout << "Enter a number: ";
int x{};
std::cin >> x;
return x;
}
int main()
{
#ifdef ENABLE_DEBUG
std::cerr << "main() called\n";
#endif
int x{ getUserInput() };
std::cout << "You entered: " << x;
return 0;
}
// #include <iostream>
// int add(int x, int y)
// {
// std::cerr << "add() called (x=" << x <<", y=" << y << ")" << '\n';
// return x + y;
// }
// void printResult(int z)
// {
// std::cout << "The answer is: " << z << '\n';
// }
// int getUserInput()
// {
// std::cout << "Enter a number: ";
// int x{};
// std::cin >> x;
// return x;
// }
// int main()
// {
// int x{ getUserInput() };
// std::cerr << "main::x = " << x << '\n';
// int y{ getUserInput() };
// std::cerr << "main::y = " << y << '\n';
// std::cout << x << " + " << y << '\n';
// int z{ add(x, 5) };
// std::cerr << "main::z = " << z << '\n';
// printResult(z);
// return 0;
// }