1
0

hello tester command i.f.

This commit is contained in:
Captain ALM 2022-10-14 09:27:47 +01:00
commit 25f1c13adf
4 changed files with 78 additions and 0 deletions

10
Makefile Normal file
View File

@ -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

68
main.cpp Normal file
View File

@ -0,0 +1,68 @@
#include <iostream>
#include <string_view>
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;
}

BIN
main.o Normal file

Binary file not shown.

BIN
t Executable file

Binary file not shown.