jaOjaa

hore doubly nya jalan

Apr 1st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<malloc.h>
  5.  
  6. struct cust{
  7. char name[20];
  8. char city[20];
  9. int numb;
  10. char addr[30];
  11. struct cust *next;
  12. struct cust *prev;
  13. };
  14.  
  15. cust *start=NULL, *ptr;
  16.  
  17. void menu() {
  18. printf("DATABASE CUSTOMER\n");
  19. printf(". . . . . . . . .\n\n");
  20. printf("1. View customer database\n");
  21. printf("2. Add new customer\n");
  22. printf("3. Exit\n");
  23. printf("\n> Please input your choice : ");
  24. }
  25.  
  26. void add(struct cust** head_ref, int new_data) {
  27. int nnumb;
  28. char nama, alamat, kota;
  29. struct cust* new_node = (struct cust*)malloc(sizeof(struct cust));
  30. struct cust* tail = *head_ref;
  31. printf("Input company name [5..30] : ");
  32. scanf("%s", &nama);
  33. printf("Input address [5..50] : ");
  34. scanf("%s", &alamat);
  35. printf("Input city [5..30] : ");
  36. scanf("%s", &kota);
  37. printf("Input phone number : ");
  38. scanf("%d", &nnumb);
  39.  
  40. new_node->numb = new_data;
  41. new_node->next = NULL;
  42. if (ptr == NULL) {
  43. new_node->prev = NULL;
  44. *head_ref = new_node;
  45. return;
  46. }
  47. while (tail->next != NULL)
  48. tail = tail->next;
  49. tail->next = new_node;
  50. new_node->prev = tail;
  51. return;
  52. }
  53.  
  54.  
  55. int main() {
  56. int input;
  57. struct cust* head = NULL;
  58. add(&head, input);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment