С Новым годом! Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/6: Рейтинг темы: голосов - 6, средняя оценка - 5.00
0 / 0 / 0
Регистрация: 12.11.2020
Сообщений: 3

Создание базы данных

12.11.2020, 17:02. Показов 1127. Ответов 2
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Ребят, нужно сделать базу данных на 100 человек
Имя, фамилия и номер телефона
Так же должна присутствовать строка поиска в которой можно вписать данные человека и высветится нужный
Сколько не искал в ютубе, ничего толкового не смог найти
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
12.11.2020, 17:02
Ответы с готовыми решениями:

Программное создание базы данных и таблиц на C++, используя интерфейс DAO
Здравствуйте! я столкнулась с такой задачей : создать таблицу на C++, используя интерфейс DAO для Access. у меня никакой ВООБЩЕ никакой...

Создание базы данных
доброго времени суток. подскажите, как создать базу данных в visual studio 2008 c++ express? я делаю все как надо, всё как написано в...

Создание базы данных
Создать базу данных "Студенты", включающую ФИО студента, названия четырех предметов и оценки, полученные по каждому предмету. Количество...

2
0 / 0 / 0
Регистрация: 12.11.2020
Сообщений: 3
10.12.2020, 06:51  [ТС]
Написал свою самую первую базу данных на с++, помогите пожалуйста найти ошибки в ней
хотелось бы еще добавить поиск не только по айди


C++
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
 
using namespace std;
 
void input();
void search();
void edit();
void displayAll();
void fired();
int main()
{
    system("cls");
    system("color 0f");
    cout << "Please enter choice" << endl;
    cout << "1.Input new student" << endl;
    cout << "2.Search for student by ID " << endl;
    cout << "3.Edit an existing student information" << endl;
    cout << "4.Display all students" << endl;
    cout << "5.Delete student" << endl;
    cout << "6.Exit" << endl;
 
    int choice;
    cin >> choice;
 
    switch (choice) {
    case 1:
        input();
        break;
    case 2:
        search();
        break;
    case 3:
        edit();
        break;
    case 4:
        displayAll();
        break;
    case 5:
        fired();
        break;
    }
}
void fired()
{
    system("cls");
    system("cls");
    string fname;
    string mname;
    string fileName;
    string decision;
    int stdId;
    int telefonenumber;
    int thrw;
 
    cout << "Enter Student ID Number:";
    cin >> stdId;
    string stdId2 = to_string(stdId);
    stdId2.append(".txt");
    ifstream student(stdId2);
    while (student >> fname >> mname >> thrw >> telefonenumber) {
        int mnameLength = mname.size();;
        int fnameLength = fname.size();
        int lengthTotal = fnameLength + mnameLength;
 
        string answer;
        cout << "Is this the correct student?[y/n]" << endl;
        cout << fname << ' ' << mname << ' ' << endl;
        cin >> answer;
 
        if (answer == "y") {
            system("cls");
            cout << "Name";
            for (int y = 1; y < lengthTotal; y++) {
                cout << " ";
            }
            cout << "Telefone number";
            for (int i = 0; i < 0; ++i) {
                cout << " ";
            }
            cout << ' ' << endl;
            cout << fname << ' ' << mname << ' ' << telefonenumber << ' ' << stdId << endl;
            cout << "Do you wish to delete this student from the database?" << endl;
            cin >> decision;
 
            if (decision == "y") {
                string stdId3 = stdId2.replace(stdId2.begin(), stdId2.end(), " ");
                student.close();
            }
        }
 
        system("pause");
        main();
    }
}
void input()
{
    system("cls");
    string fname;
    string mname;
    string fileName;
    int stdId;
    int telefonenumber;
 
    cout << "Input first name:";
    cin >> fname;
    cout << "Input middle name:";
    cin >> mname;
    cout << "Input student telefone number:";
    cin >> telefonenumber;
    cout << "Input Id number:";
    cin >> stdId;
    string stdId2 = to_string(stdId);
    stdId2.append(".txt");
 
    ofstream newstudent(stdId2);
    newstudent << fname << ' ' << mname << ' ' << stdId << ' ' << telefonenumber << endl;
    newstudent.close();
    ofstream dir("directory.txt", ios::app);
    dir << fname << ' ' << mname << ' ' << stdId << ' ' << telefonenumber << endl;
    dir.close();
    main();
}
void search()
{
    system("cls");
    string fname;
    string mname;
    string fileName;
    int stdId;
    int thrw;
    int telefonenumber;
    cout << "Enter student ID number:";
    cin >> stdId;
    string stdId2 = to_string(stdId);
    stdId2.append(".txt");
 
    ifstream student(stdId2);
    while (student >> fname >> mname >> thrw >> telefonenumber) {
        int mnameLength = mname.size();
        int fnameLength = fname.size();
        int lengthTotal = fnameLength + mnameLength;
 
        string answer;
        cout << "Is this the correct student?[y/n]" << endl;
        cout << fname << ' ' << mname << ' ' << endl;
        cin >> answer;
 
        if (answer == "y") {
            system("cls");
            cout << "Name";
            for (int y = 1; y < lengthTotal; y++) {
                cout << " ";
            }
            cout << "Telefone number";
            for (int i = 0; i < 0; ++i) {
                cout << " ";
            }
            cout << ' ' << endl;
            cout << fname << ' ' << mname << ' ' << telefonenumber << ' ' << stdId << endl;
        }
 
    }
    system("pause");
    main();
}
 
void edit()
{
    system("cls");
    string fname;
    string mname;
    string newfname;
    string newmname;
    string decision;
    int stdId;
    int telefonenumber;
    int newtelefonenumber;
    int thrw;
    cout << "Enter the student Id of the student whose data you wish to edit:";
    cin >> stdId;
    string stdId2 = to_string(stdId);
    stdId2.append(".txt");
    ifstream student(stdId2);
    while (student >> fname >> mname >> thrw >> telefonenumber) {
 
        cout << "Is this the student that you wish to edit?[y/n]" << endl;
        cout << fname << ' ' << mname << ' ' << endl;
        cin >> decision;
        if (decision == "y") {
            system("cls");
 
            int mnameLength = mname.size();
            int fnameLength = fname.size();
            int lengthTotal = fnameLength + mnameLength;
            cout << "Name";
            for (int y = 1; y < lengthTotal; y++) {
                cout << " ";
            }
            cout << "Telefone number";
            for (int i = 0; i < 0; ++i) {
                cout << " ";
            }
            cout << ' ' << endl;
 
 
            cout << fname << ' ' << mname << ' '  << telefonenumber << ' ' << stdId << endl;
            cout << "Enter new first name:";
            cin >> newfname;
            cout << "Enter new middle name:";
            cin >> newmname;
            cout << "Enter new telefone number:";
            cin >> newtelefonenumber;
        }
        if (decision == "n") {
            main();
        }
        student.close();
        ofstream student2(stdId2);
        student2 << newfname << ' ' << newmname << ' ' << stdId << ' ' << telefonenumber << endl;
        student2.close();
    }
 
    main();
}
void displayAll()
{
    system("cls");
    string fname;
    string mname;
    int telefonenumber;
    int stdId;
 
    cout << "Entire student database" << endl;
    cout << "------------------------" << endl;
    ifstream dir("directory.txt");
    while (dir >> fname >> mname >> telefonenumber >> stdId) {
        cout << fname << ' ' << mname << ' ' << telefonenumber << ' ' << stdId << endl;
    }
    system("pause");
    main();
}
0
0 / 0 / 0
Регистрация: 12.11.2020
Сообщений: 3
10.12.2020, 07:01  [ТС]
Ребят, написал свою первую базу данных, помогите пожалуйста найти ошибки в коде, и подскажите как добавить поиск не только по айди,заранее благодарен
C++
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
 
using namespace std;
 
void input();
void search();
void edit();
void displayAll();
void fired();
int main()
{
system("cls");
system("title ItalyHorse45 Databse Program");
system("color 0f");
cout << "Please enter choice" << endl;
cout << "1.Input new employee" << endl;
cout << "2.Search for an employee by ID number" << endl;
cout << "3.Edit an existing employee's information" << endl;
cout << "4.Display all Employees" << endl;
cout << "5.Delete Employee" << endl;
cout << "6.Exit" << endl;
 
int choice;
cin >> choice;
 
switch (choice){
case 1:
    input();
    break;
case 2:
    search();
    break;
case 3:
    edit();
    break;
case 4:
    displayAll();
    break;
case 5:
    fired();
    break;
}
}
void fired()
{
    system("cls");
    system("cls");
    string fname;
    string mname;
    string lname;
    string fileName;
    string decision;
    double salary;
    int empId;
    int age;
    int thrw;
 
    cout << "Enter Employee ID Number:";
        cin >> empId;
        string empId2 = to_string(empId);
        empId2.append(".txt");
        ifstream employee(empId2);
        while (employee >> fname >> mname >> lname >> thrw >> salary >> age){
            int mnameLength = mname.size();
            int lnameLength = lname.size();
            int fnameLength = fname.size();
            int lengthTotal = fnameLength + lnameLength + mnameLength;
 
            string answer;
            cout << "Is this the correct employee?[y/n]" << endl;
            cout << fname << ' ' << mname << ' ' << lname << endl;
            cin >> answer;
 
            if (answer == "y"){
                system("cls");
                cout << "Name";
                for (int y = 1; y < lengthTotal; y++){
                    cout << " ";
                }
                cout << "Age";
                for (int z = 1; z < 2; z++){
                    cout << " ";
                }
                cout << "Salary";
                cout << "ID#" << endl;
                for (int x = 1; x < lengthTotal + 20; x++){
                    cout << "-";
                }
                cout << ' ' << endl;
                cout << fname << ' ' << mname << ' ' << lname << ' ' << age << ' ' << "$" << salary << ' ' << empId << endl;
                cout << "Do you wish to delete this employee from the database?" << endl;
                cin >> decision;
                
                if (decision == "y"){
                    string empId3 = empId2.replace(empId2.begin(), empId2.end(), " ");
                    employee.close();
                }
            }
 
            system("pause");
            main();
        }
}
void input ()
{
    system("cls");
    string fname;
    string mname;
    string lname;
    string fileName;
    double salary;
    int empId;
    int age;
 
    cout << "Input first name:" ;
    cin >> fname;
    cout << "Input middle name:";
    cin >> mname;
    cout << "Input last name:";
    cin >> lname;
    cout << "Input employee age:";
    cin >> age;
    cout << "Input employee salary:";
    cin >> salary;
    cout << "Input Id number:";
    cin >> empId;
    string empId2 = to_string(empId);
    empId2.append(".txt");
 
    ofstream newemployee(empId2);
    newemployee << fname << ' ' << mname << ' ' << lname << ' ' << empId << ' ' << salary << ' ' << age << endl;
    newemployee.close();
    ofstream dir("directory.txt", ios::app);
    dir << fname << ' ' << mname << ' ' << lname << ' ' << empId << ' ' << salary << ' ' << age << endl;
    dir.close();
    main();
}
void search()
{
    system("cls");
    string fname;
    string mname;
    string lname;
    string fileName;
    double salary;
    int empId;
    int thrw;
    int age;
    cout << "Enter emplyee ID number:";
    cin >> empId;
    string empId2 = to_string(empId);
    empId2.append(".txt");
 
    ifstream employee(empId2);
    while(employee >> fname >> mname >> lname >> thrw >> salary >> age  ){
        int mnameLength = mname.size();
        int lnameLength = lname.size();
        int fnameLength = fname.size();
        int lengthTotal = fnameLength + lnameLength + mnameLength;
 
        string answer;
        cout << "Is this the correct employee?[y/n]" << endl;
        cout << fname << ' ' << mname << ' ' << lname << endl;
        cin >> answer;
 
        if (answer == "y"){
            system("cls");
            cout << "Name";
            for (int y = 1; y<lengthTotal;y++){
                cout <<  " ";
            }
            cout << "Age";
            for (int z=1;z<2;z++){
            cout << " ";
            }
            cout << "Salary";
            cout << "ID#" << endl;
            for (int x=1;x<lengthTotal + 20;x++){
            cout << "-";
            }
            cout << ' ' << endl;    
            cout << fname << ' ' << mname <<  ' ' << lname << ' ' << age << ' ' << "$" << salary << ' ' << empId << endl;
        }
 
        }
    system("pause");
    main();
    }
 
void edit()
{
    system("cls");
    string fname;
    string mname;
    string lname;
    string newfname;
    string newmname;
    string newlname;
    string decision;
    int empId;
    int age;
    int newage;
    int thrw;
    double salary;
    double newsalary;
    cout << "Enter the Employee Id of the Employee whose data you wish to edit:";
        cin >> empId;
    string empId2 = to_string(empId);
    empId2.append(".txt");
    ifstream employee(empId2);
    while (employee >> fname >> mname >> lname >> thrw >> salary >> age)  {
        cout << "Is this the Employee that you wish to edit?[y/n]" << endl;
        cout << fname << ' ' << mname << ' ' << lname << endl;
        cin >> decision; 
            if (decision == "y"){
            system("cls");
            cout << "Current information:" << endl;
            
            int mnameLength = mname.size();
            int fnameLength = fname.size();
            int lnameLength = lname.size();
            int lengthTotal = lnameLength + fnameLength + mnameLength;
            cout <<"Name";
            for (int y = 1; y<lengthTotal;y++){
                cout << " ";
            }
            cout << "Age";
            for (int z = 1;z<2;z++){
                cout << " " ;
            }
            cout << "Salary";
            cout << "ID#" << endl;
            for (int x=1;x<lengthTotal+ 17;x++){
                cout << "-";
            }
            cout << ' ' << endl;
        
                
                cout << fname << ' ' << mname << ' ' << lname << ' ' << age << ' ' << salary << ' ' << empId << endl;
                cout << "Enter new first name:";
                cin >> newfname;
                cout << "Enter new middle name:";
                cin >> newmname;
                cout << "Enter new last name:";
                cin >> newlname;
                cout << "Enter new age:";
                cin >> newage;
                cout << "Enter new salary";
                cin >> newsalary;
            }
            if (decision == "n"){
            main();
            }
    employee.close();
    ofstream employee2(empId2);
    employee2 << newfname << ' ' << newmname << ' ' << newlname << ' ' << empId << ' ' << newsalary << ' ' << newage << endl ;
    employee2.close();
    }
    
    main();
}
void displayAll()
{
    system("cls");
    string fname;
    string mname;
    string lname;
    int age;
    double salary;
    int empId;
 
    cout << "Entire Employee database" << endl;
    cout << "------------------------" << endl;
    ifstream dir("directory.txt");
    while (dir >> fname >> mname >> lname >> age >> empId >> salary){
        cout << fname << ' ' << mname << ' ' << lname << ' ' << age << ' ' << salary << empId << endl;
    }
    system("pause");
    main();
}
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
10.12.2020, 07:01
Помогаю со студенческими работами здесь

Создание базы данных VS C++
всем добрый вечер. проблемка) хочу создать приложение windows и там же небольшую базу данных. создаю форму. потом захожу Проект...

создание базы данных
Здраствуйте! Нужно сделать чтоб программа сама создавала файл с базой данных с определенным названием и потом работала с ней. Работать с...

Создание Базы Данных в С++
Всем Доброго Времени Суток!! У меня такой вопрос. Я пытаюсь создать Базу Данных в Visual C++ 2008 Express, чтобы попрактиковать SQL через...

создание базы данных
помогите исправить ошибки в базе данных студентов и дописать функции поиска студента по фамилии, сортировки по возрастанию среднего...

Создание базы данных
Прежде всего прошу прощения за созданную тему.:pardon: Прошу меня направить в правильном напрвлении так как это моя первая база данных...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Новые блоги и статьи
сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11 — это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11 Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
Модель микоризы: классовый агентный подход 3
anaschu 06.01.2026
aa0a7f55b50dd51c5ec569d2d10c54f6/ O1rJuneU_ls https:/ / vkvideo. ru/ video-115721503_456239114
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR
ФедосеевПавел 06.01.2026
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR ВВЕДЕНИЕ Введу сокращения: аналоговый ПИД — ПИД регулятор с управляющим выходом в виде числа в диапазоне от 0% до. . .
Модель микоризы: классовый агентный подход 2
anaschu 06.01.2026
репозиторий https:/ / github. com/ shumilovas/ fungi ветка по-частям. коммит Create переделка под биомассу. txt вход sc, но sm считается внутри мицелия. кстати, обьем тоже должен там считаться. . . .
Расчёт токов в цепи постоянного тока
igorrr37 05.01.2026
/ * Дана цепь постоянного тока с сопротивлениями и источниками (напряжения, ЭДС и тока). Найти токи и напряжения во всех элементах. Программа составляет систему уравнений по 1 и 2 законам Кирхгофа и. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru