include iostream using namespace std struct foundation char name 40 ch

 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
#include <iostream>
using namespace std;
struct foundation {
char name[40];
char city[40];
};
int main() {
struct foundation founds[2];
string query;
for (auto &element: founds) {
cout << "Enter name / city" << endl;
cin >> element.name >> element.city;
}
for (auto &element: founds) {
cout << element.name << " - " << element.city << endl;
}
cout << "Enter the name of the structure you want to delete." << endl;
cin >> query;
for (auto &element: founds) {
if (element.name == query) {
*element.name = '\0';
*element.city = '\0';
cout << "Structure with name " << query << " has been removed." << endl;
}
}
for (auto &element: founds) {
cout << element.name << " - " << element.city << endl;
}
return 0;
}