From 892c5b197050107010075f8bd0fcd675ca192e0c Mon Sep 17 00:00:00 2001 From: cyborg1811m Date: Sat, 30 Dec 2023 21:31:16 +0100 Subject: [PATCH] V1 --- main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..8d10afe --- /dev/null +++ b/main.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + + +int main() { + + std::cout << "Enter To-Minify: \n" + "Press Ctrl+d (Unix) or Ctrl+z followed by Enter on a new line (Windows) to confirm input\n" + "Press Ctrl+c or enter an empty string to exit" << std::endl; + + std::string input; + std::getline(std::cin, input, static_cast(EOF)); + std::cin.clear(); + + if (input.empty()) + return 0; + + std::replace_if(input.begin(), input.end(), [] (char c) { return isspace(c); }, ' '); + + std::string output; + std::unique_copy(input.begin(), input.end(), std::back_insert_iterator(output), + [](char i, char in){ return std::isspace(i) && std::isspace(in); }); + + std::cout << "----------------------------------------\n"; + std::cout << output << "\n" << std::endl; + + return 0; +} \ No newline at end of file