CODE
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define FALSE 0;
#define TRUE 1;
typedef char string10[11];
typedef char string20[21];
struct CustRec{
string10 Name;
string20 Address;
struct CustRec *Prev, *Next;
};
typedef struct CustRec *CustPtr;
CustPtr FirstCust, LastCust, PrevCust, CurrentCust;
void AddRecord(string10 N, string20 A)
{
if(FirstCust == NULL){
CurrentCust = malloc(sizeof(struct CustRec));
strcpy(CurrentCust->Name,N);
strcpy(CurrentCust->Address,A);
CurrentCust->Next = NULL;
CurrentCust->Prev = NULL;
FirstCust = CurrentCust;
LastCust = CurrentCust;
}
else {
PrevCust = LastCust;
CurrentCust = malloc(sizeof(struct CustRec));
strcpy(CurrentCust->Name,N);
strcpy(CurrentCust->Address,A);
PrevCust->Next = CurrentCust;
CurrentCust->Next = NULL;
CurrentCust->Prev = PrevCust;
LastCust = CurrentCust;
}
}
void ListForwards(void)
{
CurrentCust = FirstCust;
while (CurrentCust !=NULL)
{
printf("Name : %s\n",CurrentCust->Name);
printf("Address : %s\n",CurrentCust->Address);
CurrentCust = CurrentCust->Next;
}
printf("\n");
}
void ListBackwards(void)
{
CurrentCust = LastCust;
while (CurrentCust !=NULL) {
printf("Name : %s\n", CurrentCust->Name);
printf("Address : %s\n", CurrentCust->Address);
CurrentCust = CurrentCust->Prev;
}
printf("\n");
}// ListBackwards ends here.
void DEL
{
???????
???????
???????
??????
??????
}
int main(void)
{
FirstCust = NULL;
LastCust = NULL;
PrevCust = NULL;
CurrentCust = NULL;
AddRecord("Bernil","Ecoland");
AddRecord("Andrei","Nova Tierra");
AddRecord("Loresh","Central Park");
AddRecord("Carinna","Ladislawa");
AddRecord("Jovan","Woodridge");
ListForwards();
ListBackwards();
ListForwards();
getch();
}
QUOTE
how can i make a delete func() in this code... please guide me or give some tips to read about... tnx