Question
Write a C function that asks the user to input a telephone number as a string containing a threedigit area code, followed by a seven-digit
Write a C function that asks the user to input a telephone number as a string containing a threedigit 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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started