commit 892c5b197050107010075f8bd0fcd675ca192e0c Author: cyborg1811m Date: Sat Dec 30 21:31:16 2023 +0100 V1 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