We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84d136a commit f5cb1cfCopy full SHA for f5cb1cf
ex01/main.cpp
@@ -0,0 +1,25 @@
1
+#include "RPN.hpp"
2
+
3
+int main(int ac, char** av)
4
+{
5
+ if (ac < 2) {
6
+ std::cerr << "Error: Invalid number of arguments." << std::endl;
7
+ return 1;
8
+ }
9
+ std::string expression;
10
+ for (int i = 1; i < ac; ++i)
11
+ {
12
+ expression += av[i];
13
+ if (i < ac - 1)
14
+ expression += " ";
15
16
+ try {
17
+ int result = RPN::evaluate(expression);
18
19
+ std::cout << "Result: " << result << std::endl;
20
+ } catch (const std::exception &e) {
21
+ std::cerr << e.what() << std::endl;
22
23
24
+ return 0;
25
+}
0 commit comments