## Function to Show Customer Order

Any Idea how to output customer order Like this below picture, so in Menu 2(Cancel Item), Can popAll (Delete All the Order):

Code:
```#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int count = 1;
struct data{
char nama[100];
char type[25];
int qty;
int price;
data *next,*prev;

void pushTail(char nama[],char type[],int qty,int price)
{
current = (data*)malloc(sizeof(struct data));

strcpy(current->nama,nama);
strcpy(current->type,type);
current->qty = qty;
current->price = price;
current->next=current->prev=NULL;

{
}
else
{
current->prev=tail;
tail->next=current;
tail=current;
}
}

printf("No data");
free(current);
}else{
free(current);
}
}

void popAll(){
}
}

int jumlah()
{
int jumlah = 0;
while(current!=NULL)
{
jumlah++;
current=current->next;
}
return jumlah;
}

int stokBarang(int nilai)
{
int hitung = nilai-1;
while(current!=NULL && hitung!=0)
{
current = current->next;
cek = current->qty;
hitung--;
}
return cek;
}

void popMid(int nilai)
{
int count = nilai-1;
while(current!=NULL && count!=0)
{
current = current->next;
hapus = current->price;
count--;
}
{
free(current);
}
else{
{
free(current);
}
else if(hapus==tail->price)
{
current=tail;
tail=tail->prev;
tail->next=NULL;
free(current);
}
else
{
current->prev->next=current->next;
current->next->prev=current->prev;
free(current);
}
}
}

void view()
{
int i = 0;
if(current==NULL)
{
printf("No Data\n");
}
else
{
printf("===============================================================================");
printf("                          +++++ Brew Coffee Shop +++++                             ");
printf("=============================================================================== ");
printf("No.| %-20s | %-10s | %-12s | %-20s  |\n","Menu","Type","Quantity","Price");
printf("-------------------------------------------------------------------------------");
printf("\n");
while(current!=NULL)
{
printf("%-3d| %-20s | %10s | %12d | %10d            |\n",i+1,current->nama,current->type,current->qty,current->price);
current=current->next;
i++;
}
printf("-------------------------------------------------------------------------------");
}
}

void viewOrder()
{

}

void viewCustomer(char name[])
{
int i = 0;
if(current==NULL)
{
printf("No Data\n");
}
else
{
printf("===============================================================================");
printf("                          +++++ Brew Coffee Shop +++++                             ");
printf("Welcome, Mr./Mrs. %s\n\n\n",name);
printf("=============================================================================== ");
printf("No.| %-20s | %-10s | %-12s | %-20s  |\n","Menu","Type","Quantity","Price");
printf("-------------------------------------------------------------------------------");
printf("\n");
while(current!=NULL)
{
printf("%-3d| %-20s | %10s | %12d | %10d            |\n",i+1,current->nama,current->type,current->qty,current->price);
current=current->next;
i++;
}
printf("-------------------------------------------------------------------------------");
}
}

int main()
{
int banyak=  jumlah();
int choose;
int angka;
char nama[100];
char type[10];
int qty;
int jumlah1;
int price;
char customerName[25];
int pilihanCustomer;
int jumlahOrder;
int banyakBarang;

int pilihan;
do{
printf("================================================================================\n");
printf("                          +++++ Brew Coffee Shop +++++                          \n");
printf("================================================================================\n");
printf("3. Exit\n");
printf("\n");
scanf("%d",&pilihan);fflush(stdin);

switch(pilihan)
{
case 1:

{
getchar();
system("cls");
}
{
system("cls");
int pilih;
do{
if(count==1)
{
pushTail("Americano","Coffee",24,19000);
pushTail("Chocolate Baked","Non-coffee",15,24000);
pushTail("Alberto","Coffee",7,44000);
count++;
}
system("cls");
view();
printf("2. Remove item\n");
printf("3. Exit\n");
scanf("%d",&pilih);fflush(stdin);
switch(pilih)
{
case 1:
do{
printf("Insert item name: ");
scanf("%[^\n]",&nama);fflush(stdin);
}while(strlen(nama) < 5 || strlen(nama) > 20);

do{
printf("Type of Coffee[yes/no]: ");
scanf("%s",&type);fflush(stdin);fflush(stdin);
}while(strcmp(type,"yes")!=0 && strcmp(type,"no")!=0);

do{
printf("Insert the quantity of the item: ");
scanf("%d",&qty);fflush(stdin);
}while(qty < 1 || qty > 100);

do{
printf("Insert the price of the item: ");
scanf("%d",&price);fflush(stdin);
}while(price < 10000 || price > 200000);
if(strcmp(type,"yes")==0)
{
pushTail(nama,"Coffee",qty,price);
}
else
{
pushTail(nama,"Non-coffee",qty,price);
}

break;
case 2:
jumlah1 = jumlah();
do{
printf("Choose Number to Delete [1 - %d]: ",jumlah1);
scanf("%d",&angka);fflush(stdin);
}while(angka < 1 || angka > jumlah1);

popMid(angka);
break;
case 3:
system("cls");
return main();
break;
}
}while(pilih!=3 || pilih < 1 || pilih > 3);

}

break;
case 2:
scanf("%[^\n]",&customerName);fflush(stdin);
system("cls");
if(count==1)
{
pushTail("Americano","Coffee",24,19000);
pushTail("Chocolate Baked","Non-coffee",15,24000);
pushTail("Alberto","Coffee",7,44000);
count++;
}

do{
system("cls");
viewCustomer(customerName);
printf("2. Cancel item\n");
printf("3. Exit\n");
scanf("%d",&pilihanCustomer);fflush(stdin);
switch(pilihanCustomer)
{
case 1:
jumlah1 = jumlah();
do{
scanf("%d",&angka);fflush(stdin);
}while(angka < 1 || angka > jumlah1);
banyakBarang = stokBarang(angka);
do{
printf("enter the quantity [1 - %d]: ",banyakBarang);
scanf("%d",&jumlahOrder);fflush(stdin);
}while(jumlahOrder < 1 || jumlahOrder > banyakBarang);

getchar();
break;
case 2:

break;
case 3:
system("cls");
return main();
break;
}
}while(pilihanCustomer!=3 || pilihanCustomer ==1 || pilihanCustomer==2);
break;
}
}while(pilihan < 1 || pilihan >3 || pilihan ==1 || pilihan==2 || pilihan !=3);
}```
Any Idea would be so much help for me, thank you