int main char fileName new char 50 char buf_name new char 20 char buf_

 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
int main()
{
char* fileName = new char[50];
char* buf_name = new char[20];
char* buf_value = new char [10];
dyn_list vars; // Динамический список
cout << "Enter name of file -> ";
cin >> fileName;
ifstream* inp = new ifstream(fileName);
if (!inp->good())
{
cout << "File opening error!\n";
system("PAUSE");
return 0;
}
constr_list(vars);
while (!inp->eof())
{
inp->getline(buf_name, 20, ' ');
inp->getline(buf_value, 10, ' ');
comp_in(vars, buf_name, buf_value);
}
inp->close();
comp* p = new comp();
p = search(vars, "z");
if (p)
comp_del(vars, p);
p = search(vars, "abc");
if (p)
comp_edit(*p, "2");
ofstream* out = new ofstream(fileName);
while (vars.head != NULL)
{
out->write(vars.head->name, strlen(vars.head->name));
out->write(" ",1);
out->write(vars.head->value, strlen(vars.head->value));
out->write(" ",1);
vars.head = vars.head->next;
}
out->close();
system("PAUSE");
return 0;
}