Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<stdio.h>
- #include<conio.h>
- #include<malloc.h>
- struct cust{
- char name[20];
- char city[20];
- int numb;
- char addr[30];
- struct cust *next;
- struct cust *prev;
- };
- cust *start=NULL, *ptr;
- void menu() {
- printf("DATABASE CUSTOMER\n");
- printf(". . . . . . . . .\n\n");
- printf("1. View customer database\n");
- printf("2. Add new customer\n");
- printf("3. Exit\n");
- printf("\n> Please input your choice : ");
- }
- void add(struct cust** head_ref, int new_data) {
- int nnumb;
- char nama, alamat, kota;
- struct cust* new_node = (struct cust*)malloc(sizeof(struct cust));
- struct cust* tail = *head_ref;
- printf("Input company name [5..30] : ");
- scanf("%s", &nama);
- printf("Input address [5..50] : ");
- scanf("%s", &alamat);
- printf("Input city [5..30] : ");
- scanf("%s", &kota);
- printf("Input phone number : ");
- scanf("%d", &nnumb);
- new_node->numb = new_data;
- new_node->next = NULL;
- if (ptr == NULL) {
- new_node->prev = NULL;
- *head_ref = new_node;
- return;
- }
- while (tail->next != NULL)
- tail = tail->next;
- tail->next = new_node;
- new_node->prev = tail;
- return;
- }
- int main() {
- int input;
- struct cust* head = NULL;
- add(&head, input);
- }
Advertisement
Add Comment
Please, Sign In to add comment