about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-03-20 10:39:25 +0100
committerChristian Krinitsin <mail@krinitsin.com>2025-03-20 10:39:25 +0100
commit481c97567aa1cb54edd169841d1266a7a59a0227 (patch)
treec82abc1acb363e72806dc8842a45fc928d2d6c3b
parent3361ed6970f877d5207b4de271f882d39ea3fe7b (diff)
downloadBT-Programming-Assignment-481c97567aa1cb54edd169841d1266a7a59a0227.tar.gz
BT-Programming-Assignment-481c97567aa1cb54edd169841d1266a7a59a0227.zip
server: convert program argument to integer
-rw-r--r--server/src/main.cpp11
-rw-r--r--src/server/main.cpp25
2 files changed, 25 insertions, 11 deletions
diff --git a/server/src/main.cpp b/server/src/main.cpp
deleted file mode 100644
index 26bee21..0000000
--- a/server/src/main.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <cstdio>
-
-int main(int argc, char* argv[])
-{
-    if (argc != 2) {
-        std::printf("The size of the hash table is needed");
-        return 1;
-    }
-
-    return 0;
-}
diff --git a/src/server/main.cpp b/src/server/main.cpp
new file mode 100644
index 0000000..e04a1cf
--- /dev/null
+++ b/src/server/main.cpp
@@ -0,0 +1,25 @@
+#include <cstdint>
+#include <cstdio>
+#include <stdexcept>
+#include <string>
+
+#include "hashtable.h"
+
+int main(int argc, char* argv[])
+{
+    if (argc != 2) {
+        std::printf("One argument required");
+        return 1;
+    }
+
+    uint32_t size;
+    try {
+        size = std::stoi(std::string(argv[1]));
+    } catch (const std::invalid_argument& e) {
+        std::printf("Invalid argument");
+        return 1;
+    }
+
+
+    return 0;
+}