-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (64 loc) · 1.55 KB
/
main.cpp
File metadata and controls
65 lines (64 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "mylib.h"//Подключаем заголовочный файл
using namespace std;
int main(int argc, char *argv[]){
string namefile;
namefile=argv[1];
cout << "Good morning."<<endl;
string s;//На случай смены файла с данными
int n;
int k=0;
fstream file1;
fstream file2;
while (k==0){//Цикл по k
cout <<"Your Database name right now is: "<< namefile<<endl;
cout <<"Press:"<<endl;
cout <<"1- to see all our materials"<<endl;
cout <<"2- to find specific bricks type"<<endl;
cout <<"3- to add materials"<<endl;
cout <<"4- to delete materials"<<endl;
cout <<"8- to clear all database"<<endl;
cout <<"9- to change database"<<endl;
cout <<"0- to stop working with database"<<endl;
cin >> n;
void (*func)(string namefile);//Указатель на функцию
switch (n){
case 0:
exit(0);
break;
case 1:
func=allwrite;
break;
case 2:
func=search;
break;
case 3:
func=add;
break;
case 4:
func=deleting;
break;
case 8:
func=allclear;
break;
case 9:
cout <<"Please enter new database name:(txt file!)"<<endl;
cin >> s;
file2.open(s);
if(!file2){
cout <<"Sorry, database can not be found. Please try again"<<endl;
}
else{
cout<<"Database changed sucsessfully"<<endl;
namefile=s;
}
file2.close();break;
default:
cout<<"You uncorrect data. Please, try again"<<endl;
break;
}
if ((n==1)||(n==2)||(n==3)||(n==4)||(n==8)){
func(namefile); //Вызов соответствующей функции
}
}
return 0;
}