Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Explain the main elements of a sustainable work system

Answered: 1 week ago

Question

Explain the nature of paid work

Answered: 1 week ago