From 19f1a70edbf2b08536c114e12f7b3c1e77469730 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 14 Aug 2024 19:58:58 +0200 Subject: Forgot how painful input buffers are --- 3p39.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 3p39.cpp (limited to '3p39.cpp') diff --git a/3p39.cpp b/3p39.cpp new file mode 100644 index 0000000..6f25e86 --- /dev/null +++ b/3p39.cpp @@ -0,0 +1,51 @@ +#include +#include +#include "sales_data.hpp" +#include "sales_item.hpp" +#include +#include +#include + +/* + * + * 3.39 + * + * + */ + +int main () { + + std::string s1; + std::string s2; + if(std::cin >> s1 >> s2) {} else { return -1; } + if(s1 == s2) { + std::cout << "Both strings are equal!" << std::endl; + } else { + std::cout << "The strings are not equal!" << std::endl; + } + + // DUDE i forgot how painful input buffers can be!!! THIS SUCKS! This input sucks and we can only input the maximum characters but whatever im not spending more time on this exercise + constexpr size_t cstring_size = 10; + char cs1[cstring_size]; + char cs2[cstring_size]; + cs1[0] = '\0'; + cs2[0] = '\0'; + for(size_t i = 0 ; i != cstring_size-1 ; ++i) { + std::cin >> cs1[i]; + cs1[i+1] = '\0'; + } + + std::cin.ignore(std::numeric_limits::max(), '\n'); + for(size_t i = 0 ; i != cstring_size-1 ; ++i) { + std::cin >> cs2[i]; + cs2[i+1] = '\0'; + } + + if(std::strcmp(cs1, cs2) == 0) { + std::cout << "Both strings are equal!" << std::endl; + } else { + std::cout << "The strings are not equal!" << std::endl; + } + + return 0; +} -- cgit v1.2.3