WIP Borland C Doubly linked list
Hi all!
I need to create a programm wich represents doubly linked list. It should do the following
1. Create new list
2. Add new structure
3. Delete selectes dtructure
4. Load existing list from file
5.Save list to file.
It very difficult for me to understand. I've tryed to write some code. But I need somebody to help me to complete my project. I need just a little help.
Code:
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
struct item //the structure
{char name[10]; int prc; int col; // there are 3 elements in the structure name, prc, col
struct item *prev; // to previous structure
struct item *next; // to next structure
};
void build(void); // creates new structure
void view(item *); // list
struct item *head,*tail; // pointers
main()
{
//поехали!
build(); //so we create new structure
list(head); // then we can list
free(head);
}
void build(void) //create new node function
{item *p,*pr; //
pr=NULL;
printf("Creating new node\n\n");
do { p=(item *)malloc(sizeof(spis));
printf("Поле Name: "); //So we begins to fill our structure
gets(p->name); //fills the name element of the structure item
p->v1=pred;
if (pr!= NULL)
pr->next=p;
else
head=p;
pr=p;
puts(" Finish- <esc>");
}
Can somebody show me how to fill prc and cal elemens of the structure.
And then show them