Advertisement
mhdew

Phonebook

Dec 13th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. struct address{
  4. int house;
  5. char area[10];
  6. };
  7. struct add_cont{
  8. char first_name[20];
  9. char last_name[20];
  10. long long cell;
  11. struct address addr;
  12. };
  13.  
  14. int new_contact();
  15. int search_old();
  16. int main()
  17. {
  18. int entry, test;
  19. char choice[100];
  20.  
  21. printf("Welcome to Proloy Phone Book\n\n");
  22.  
  23. for(;;){
  24. printf("\nFor New Contact,\nPress 1\n");
  25. printf("\nFor Searching Old Contact,\nPress 2\n");
  26.  
  27. scanf("%d", &entry);
  28.  
  29. switch(entry){
  30. case 1:
  31. new_contact();
  32. //printf("Enter a new number:\n");
  33. //scanf("%d", &test);
  34. break;
  35. case 2:
  36. search_old();
  37. //printf("Enter a new code:\n");
  38. //scanf("%d", &test);
  39. break;
  40. default:
  41. printf("Invalid Key word\nTry again :)\n");
  42. break;
  43. }
  44.  
  45. printf("\nDo you want to continue?\nPress enter to your choice; 'Yes' or 'No'\n");
  46.  
  47. scanf("%s", choice);
  48.  
  49. if(choice[0]=='Y' || choice[0]=='y')
  50. continue;
  51. else if(choice[0]=='N' || choice[0]=='n'){
  52. printf("Thank you for using our phone book :)\n");
  53. break;
  54. }
  55. else{
  56. printf("Invalid Key word :/\n");
  57. printf("\nDo you want to continue?\nPress enter to your choice; 'Yes' or 'No'\n");
  58. scanf("%s", choice);
  59. }
  60. }
  61.  
  62. return 0;
  63. }
  64.  
  65. int new_contact()
  66. {
  67. struct add_cont in1[10];
  68. int i=0, n, p;
  69. char choice[4];
  70. i=0;
  71.  
  72. for(;;){
  73. i++;
  74.  
  75. printf("Enter your first name :");
  76. scanf("%s", in1[i].first_name);
  77. printf("Enter your last name :");
  78. scanf("%s", in1[i].last_name);
  79. printf("Enter your cell number :");
  80. scanf("%lld", &in1[i].cell);
  81. printf("Enter your address :");
  82. scanf("%lld", &in1[i].addr.house);
  83. scanf("%s", in1[i].addr.area);
  84.  
  85. // i++;
  86.  
  87. printf("\nDo you want to save another contact?\nIf you want, enter 'yes'\nIf you do not want, enter 'No'\n");
  88. scanf("%s", choice);
  89.  
  90. if(choice[0]=='y')
  91. continue;
  92. else
  93. //return i;
  94. break;
  95.  
  96. }
  97.  
  98. printf("Enter the key word\t:");
  99. scanf("%d", &p);
  100. if(p>i)
  101. printf("Invalid :/\n");
  102. else
  103. printf("\nName\t: %s %s\nCell No\t: %011lld\nAddress\t: %d,%s\n", in1[p].first_name,in1[p].last_name,in1[p].cell,in1[p].addr.house,in1[p].addr.area);
  104.  
  105. }
  106. int search_old()
  107. {
  108. // int n;
  109.  
  110. // n=new_contact(n);
  111. // printf("%d\n", n);
  112.  
  113. // if(i==0)
  114. //
  115. printf("Vuila gesi :3\n");
  116.  
  117. // return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement