" РАБОТА СО СПИСКОМ "Помогите с этой задачкой...
Из пяти ошибок осталась дна, а в что тут не так даже не пойму...
[codebox]include <stdio.h>
#include <stdlib.h>
struct liter {
char name [30];
char dr[10];
char proza[30];
struct liter *start;
struct liter *last;
struct liter *next;
struct liter *prior;
};
enter(),search(),save();
load(),menu_select(),mdelete();
{
for (;:lol:
{
switch (menu_select()) {
case 1: enter();
break;
case 2: search();
break;
case 3: save();
break;
case 4: load();
break;
case 5: exit();
}
}
return 0;
}
{
menu_select()
printf ("1. Vvod imeni\n");
printf ("2. Poisk\n");
printf ("3. Sohranit\n");
printf ("4. Zagryzit\n");
printf ("5. Vihod\n");
}
enter()
{
struct *dann;
for (;
{
dann =(struct litera *) malloc (sizeof (struct (struct litera));
if (!info) {
printf ("\n Net svobodnoi pamati");
return;
}
inputs (" vvedite ima:", dann->name,30);
inputs (" vvedite droshdenia:", dann->dr,10);
inputs ("vvedite proizvedenia:", dann -> proza, 30);
}
}
search()
{
char name [50];
struct liter *dann;
printf ("vvedite ima:");
gets(name);
dann = dann(name);
if (!dann) printf(" Nety takova\n")
else display (dann);
}
save()
{
struct liter *info;
FILE *fp;
fp=fopen("mlist", "wb");
if (!fp) {
printf(" Nevozmoshno otkrit fail.\n");
exit(1);
}
printf(" Nevozmoshno sohranenie v faile\n");
info = start;
while(info) {
fwrite(info, sizeof (struct address), 1,fp);
info = info->next;
}
fclose(fp);
}
load()
{
struct liter *info;
FILE *fp;
fp=fopen ("mlist", "rb");
if (!fp) {
printf(" Nevozmoshno otkrit fail\n");
exit(1);
}
mdelete()
char s[80];
inputs (" vvedite ima: ",s,30);
info = find(s);
if (info) {
if (*start==info) {
*start=info->next;
if(*start) (*start)->prior = NULL;
else *last = NULL;
}
else {
info prior->next = info->next;
if(info!=*last)
info->next->prior = info->prior;
else
*last = info->prior;
}
free(info);
}
}[/codebox]