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
43
44
45
46
47
48
#include <iostream>
using namespace std;
struct foundation {
char name[40];
char city[40];
};
int main() {
cout << "Enter dimension for foundations array: ";
size_t n;
cin >> n;
struct foundation founds[2];
string query;
for (int i = 0; i < n ; ++i) {
cout << "Enter name / city" << endl;
cin >> founds[i].name >> founds[i].city;
}
for (int i = 0; i < n ; ++i) {
cout << founds[i].name << " - " << founds[i].city << endl;
}
cout << "Enter the name of the structure you want to delete." << endl;
cin >> query;
for (int i = 0; i < n ; ++i) {
if (founds[i].name == query) {
*founds[i].name = '\0';
*founds[i].city = '\0';
cout << "Structure with name " << query << " has been removed." << endl;
}
}
for (int i = 0; i < n ; ++i) {
if (*founds[i].name != '\0') {
cout << founds[i].name << " - " << founds[i].city << endl;
}
}
return 0;
}