Question: Write a function that asks the user to input a telephone number as a string containing a three-digit area code, followed by a seven-digit number.
Write a function that asks the user to input a telephone number as a string containing a three-digit area code, followed by a seven-digit number. Any other characters will be ignored, and only the first 10 digits will be considered. Assume that the string has at most 200 characters. If the user does not provide at least 10 digits, an error message should be printed out. It should report the telephone number in the format (123) 456-7890. Note that the user may choose any input format, yet the program should maintain a consistent output format. The function should be called phone_fmt . Your executable will be called phone. The function and main should be in the files phone_fmt.c, phone_fmt.h and phone.c, respectively.
a.) You must include a Makefile that will build the executable and it should be named phone
.
Examples:
Input: 1234567890
Output: (123) 456-7890
Input: abc123-456-7890
Output: (123) 456-7890
Input: 123456
Output: ERROR: Not enough digits on input!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
