Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // getName:
- void getName(struct Name *Contact)
- {
- // Contact Name Input:
- printf("Please enter the contact's first name: ");
- scanf(" %30[^\n]", Contact->firstName);
- clearKeyboard();
- printf("Do you want to enter a middle initial(s)? (y or n): ");
- if (yes())
- {
- printf("Please enter the contact's middle initial(s): ");
- scanf(" %6[^\n]", Contact->middleInitial);
- clearKeyboard();
- }
- printf("Please enter the contact's last name: ");
- scanf(" %35[^\n]", Contact->lastName);
- clearKeyboard();
- }
- // getAddress:
- void getAddress(struct Address *Contact)
- {
- // Contact Address Input:
- printf("Please enter the contact's street number: ");
- scanf(" %d", &Contact->streetNumber);
- clearKeyboard();
- do {
- Contact->streetNumber = getInt();
- if(Contact->streetNumber < 0)
- printf("*** INVALID STREET NUMBER *** <must be a positive number>: ");
- } while (Contact->streetNumber < 0);
- printf("Please enter the contact's street name: ");
- scanf(" %40[^\n]", Contact->street);
- printf("Do you want to enter an apartment number? (y or n): ");
- if (yes())
- {
- printf("Please enter the contact's apartment number: ");
- do {
- Contact->apartmentNumber = getInt();
- if (Contact->appartmentNumber < 0 )
- printf("*** INVALID APARTMENT NUMBER *** <must be a positive number>: ");
- }while (Contact->apartmentNumber < 0);
- }
- printf("Please enter the contact's postal code: ");
- scanf(" %7[^\n]", Contact->postalCode);
- clearKeyboard();
- printf("Please enter the contact's city: ");
- scanf(" %40[^\n]", Contact->city);
- clearKeyboard();
- }
- // getNumbers:
- // NOTE: Also modify this function so the cell number is
- // mandatory (don't ask to enter the cell number)
- void getNumbers(struct Numbers *Contact)
- {
- // Contact Numbers Input:
- printf("Please enter a cell phone number: ");
- scanf(" %10s", Contact->cell);
- clearKeyboard();
- printf("Do you want to enter a home phone number? (y or n): ");
- if (yes()) {
- printf("Please enter the contact's home phone number: ");
- scanf(" %10s", Contact->home);
- clearKeyboard();
- }
- printf("Do you want to enter a business phone number? (y or n): ");
- if (yes()) {
- printf("Please enter the contact's business phone number: ");
- scanf(" %10s", Contact->business);
- clearKeyboard();
- }
- }
- // getContact
- void getContact(struct Contact *contact)
- {
- getName (&contact->name);
- getAddress (&contact->address);
- getNumbers (&contact->numbers);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement