Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1.  
  2.  
  3. // getName:
  4.  
  5. void getName(struct Name *Contact)
  6.  
  7. {
  8. // Contact Name Input:
  9.  
  10. printf("Please enter the contact's first name: ");
  11. scanf(" %30[^\n]", Contact->firstName);
  12. clearKeyboard();
  13.  
  14. printf("Do you want to enter a middle initial(s)? (y or n): ");
  15.  
  16. if (yes())
  17. {
  18. printf("Please enter the contact's middle initial(s): ");
  19. scanf(" %6[^\n]", Contact->middleInitial);
  20. clearKeyboard();
  21.  
  22. }
  23.  
  24. printf("Please enter the contact's last name: ");
  25. scanf(" %35[^\n]", Contact->lastName);
  26. clearKeyboard();
  27.  
  28. }
  29.  
  30.  
  31. // getAddress:
  32.  
  33. void getAddress(struct Address *Contact)
  34.  
  35. {
  36.  
  37. // Contact Address Input:
  38.  
  39. printf("Please enter the contact's street number: ");
  40. scanf(" %d", &Contact->streetNumber);
  41. clearKeyboard();
  42.  
  43. do {
  44.  
  45. Contact->streetNumber = getInt();
  46.  
  47. if(Contact->streetNumber < 0)
  48.  
  49. printf("*** INVALID STREET NUMBER *** <must be a positive number>: ");
  50.  
  51. } while (Contact->streetNumber < 0);
  52.  
  53. printf("Please enter the contact's street name: ");
  54. scanf(" %40[^\n]", Contact->street);
  55.  
  56. printf("Do you want to enter an apartment number? (y or n): ");
  57.  
  58. if (yes())
  59. {
  60. printf("Please enter the contact's apartment number: ");
  61.  
  62. do {
  63.  
  64. Contact->apartmentNumber = getInt();
  65.  
  66. if (Contact->appartmentNumber < 0 )
  67.  
  68. printf("*** INVALID APARTMENT NUMBER *** <must be a positive number>: ");
  69.  
  70. }while (Contact->apartmentNumber < 0);
  71.  
  72. }
  73.  
  74. printf("Please enter the contact's postal code: ");
  75. scanf(" %7[^\n]", Contact->postalCode);
  76. clearKeyboard();
  77.  
  78. printf("Please enter the contact's city: ");
  79. scanf(" %40[^\n]", Contact->city);
  80. clearKeyboard();
  81.  
  82. }
  83.  
  84.  
  85.  
  86.  
  87. // getNumbers:
  88.  
  89. // NOTE: Also modify this function so the cell number is
  90.  
  91. // mandatory (don't ask to enter the cell number)
  92.  
  93.  
  94.  
  95. void getNumbers(struct Numbers *Contact)
  96.  
  97. {
  98. // Contact Numbers Input:
  99.  
  100. printf("Please enter a cell phone number: ");
  101.  
  102. scanf(" %10s", Contact->cell);
  103. clearKeyboard();
  104.  
  105. printf("Do you want to enter a home phone number? (y or n): ");
  106.  
  107. if (yes()) {
  108. printf("Please enter the contact's home phone number: ");
  109. scanf(" %10s", Contact->home);
  110. clearKeyboard();
  111.  
  112. }
  113.  
  114.  
  115. printf("Do you want to enter a business phone number? (y or n): ");
  116.  
  117. if (yes()) {
  118. printf("Please enter the contact's business phone number: ");
  119. scanf(" %10s", Contact->business);
  120. clearKeyboard();
  121.  
  122. }
  123.  
  124.  
  125.  
  126. }
  127.  
  128.  
  129.  
  130. // getContact
  131.  
  132.  
  133.  
  134. void getContact(struct Contact *contact)
  135.  
  136. {
  137. getName (&contact->name);
  138. getAddress (&contact->address);
  139. getNumbers (&contact->numbers);
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement