👍 g++ database.cpp && ./a.out
1. Add 2. Find 3. Modify a rec 4. Exit
Enter an option: 1
Enter an option: 1
Enter an option: 2
Enter an option: 1
Enter an option: 3
Enter an option: 4
👍 cat database.cpp
#include <iostream>
using namespace std;
void run() {
char option[5];
cout << "1. Add "
<< "2. Find "
<< "3. Modify a rec "
<< "4. Exit\n";
cout << "Enter an option: ";
while (cin.getline(option, 4)) {
if (*option == '1') {
} else if (*option == '2') {
} else if (*option == '3') {
} else if (*option != '4')
cout << "Wrong option\n";
else return;
cout << "Enter an option: ";
}
}
int main() {
run();
}
ch 1.10 CASE STUDY: RANDOM ACCESS FILE p43 of