OK I decided to simlify the code and join save and view functions. Of course it will be wonderful if there was no any errors. I put compiller messages near the lines. What does it want from me? %|
Code:
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
struct item
{char name[20];int prc; int col;
struct item *prev;
struct item *next;
};
void build(void);
void view(item *,FILE *in);
struct item *head,*tail;
main(){
clrscr();
build();
view(head); //Too few parameters in call to 'view(item far*,struct far*)' in function main()
}
void build(void)
{item *p,*pr;
pr=NULL;
do { p=(item *)new item;
clrscr();
printf("Name : ");
scanf("%s",&p->name);
printf("\nPrc : ");
scanf("%d",&p->prc);
printf("\nCol: ");
scanf("%d",&p->col);
p->prev=pr;
if(pr != NULL)
pr->next=p;
else
head=p;
pr=p;
printf("Esc");
}
while (getch()!=27);
tail=p;
tail->next=NULL;
}
void view(item *p,FILE *in)
{int i=1;
clrscr();
in=fopen("data.txt","wb"); //Cannot assign 'unsigned int' to 'struct far*' in function view(item far*,struct far*)
while (p != NULL)
{printf("\n %-2d %-15s\t%3d\t%3d",i,p->name, p->prc, p->col);
in=fwrite(p, sizeof(item),1,in); //Parameter 'in' is never used in function view(item far*,struct far*)
i++;
p=p->next;
getch();
}
}