commit 25f1c13adf084109a7a717e09d612d78dc5cdce2 Author: Captain ALM Date: Fri Oct 14 09:27:47 2022 +0100 hello tester command i.f. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dea385f --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +build: + g++ -c main.cpp -o main.o + g++ -o t main.o +run: build + ./t +edit: + nano main.cpp +e: edit +r: run + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..b2223df --- /dev/null +++ b/main.cpp @@ -0,0 +1,68 @@ +#include +#include + +using string = std::string; +using stringv = std::string_view; + +void printm(stringv); +void printlm(stringv); +int prompti(stringv); +string prompts(stringv); +string promptm(stringv*, int); + +int main() { + bool run {true}; + while (run){ + int input { prompti(promptm(new stringv[] { + "Enter an option:", + "0) Say hello.", + "*) Exit."}, 3)) }; + if (input == 0) + printlm("Hello."); + else{ + printlm("Bye!"); + run = false; + } + } + return 0; +} + +void printm(stringv m){ + std::cout << m; +} + +void printlm(stringv m){ + printm(m); + printm("\n"); +} + +int prompti(stringv message) { + int tr {}; + std::cout << message; + if (!(std::cin >> tr)){ + std::cin.clear(); + std::cin.ignore(); + return -1; + } + return tr; +} + +string prompt(stringv message) { + string toret {""}; + std::cout << message; + if (!(std::cin >> toret)){ + std::cin.clear(); + std::cin.ignore(); + return ""; + } + return toret; +} + +string promptm(stringv msgs[], int l) { + string tr {""}; + for (int i = 0; i < l; i++) { + tr.append(msgs[i]); + tr.append("\n"); + } + return tr; +} diff --git a/main.o b/main.o new file mode 100644 index 0000000..bf8ba7f Binary files /dev/null and b/main.o differ diff --git a/t b/t new file mode 100755 index 0000000..bd3a67c Binary files /dev/null and b/t differ