summaryrefslogtreecommitdiff
path: root/src/Utils/catchInputInt.cpp
diff options
context:
space:
mode:
authordawidg81 <dawidgorski.m@gmail.com>2026-01-26 17:24:50 +0100
committerdawidg81 <dawidgorski.m@gmail.com>2026-01-26 17:24:50 +0100
commit3806bb74674f305679efdaa2889d155531bc3643 (patch)
treedcced6c118fb6ed61824bb0bcd24d1ae6aed258c /src/Utils/catchInputInt.cpp
parentb492bfb0d4cafe69edf69f196911f1b0e64c43df (diff)
dir rename
Diffstat (limited to 'src/Utils/catchInputInt.cpp')
-rw-r--r--src/Utils/catchInputInt.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utils/catchInputInt.cpp b/src/Utils/catchInputInt.cpp
new file mode 100644
index 0000000..dd804b5
--- /dev/null
+++ b/src/Utils/catchInputInt.cpp
@@ -0,0 +1,15 @@
+#include "Utils.hpp"
+
+#include <cstdio>
+#include <iostream>
+
+int Utils::catchInputInt(int input){
+ std::cin >> input;
+
+ if (std::cin.fail()) {
+ std::cout << "error: Input failed" << std::endl;
+ return 1;
+ }
+
+ return 0;
+} \ No newline at end of file