Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(50 points) Command-line arguments, modify project 2, problem 2 (translating phone number) so the phone number is a command line argument. Example input/output: ./a.out 727-PET-CARE
(50 points) Command-line arguments, modify project 2, problem 2 (translating phone number) so the phone number is a command line argument. Example input/output: ./a.out 727-PET-CARE Output: 727-738-2273 ./a.out Output: Incorrect number of arguments. Usage: ./a.out phoneNumber ./a.out 727-PET-CARE 813-CAR-WASH Output: Incorrect number of arguments. Usage: ./a.out phoneNumber 1) Name your program command_phone.c. 2) The program should include the following function: void translate (char *word, char *phone_number); The function expects word to point to a string containing the phone number to be translated; phone_number represents the pointer pointing to the string storing the translated phone number. For example, if the word is 813-TAKE-OUT, the function will store 813-825- 3688 pointed by phone_number. 3) The program should check if the correct number of arguments are entered on the command line. If an incorrect number of arguments are entered, the program should display an message. 4) Main function displays the output. The major purpose of programming style guidelines is to make programs easy to read and understand. Good programming style helps make it possible for a person knowledgeable in the application area to quickly read a program and understand how it works. 1. Your program should begin with a comment that briefly summarizes what it does. This comment should also include your name. 2. In most cases, a function should have a brief comment above its definition describing what it does. Other than that, comments should be written only needed in order for a reader to understand what is happening. 3. Information to include in the comment for a function: name of the function, purpose of the function, meaning of each parameter, description of return value (if any), description of side effects (if any, such as modifying external variables) 4. Variable names and function names should be sufficiently descriptive that a knowledgeable reader can easily understand what the variable means and what the function does. If this is not possible, comments should be added to make the meaning clear. 5. Use consistent indentation to emphasize block structure. 6. Full line comments inside function bodies should conform to the indentation of the code where they appear. 7. Macro definitions (#define) should be used for defining symbolic names for numeric constants. For example: #define PI 3.141592 8. Use names of moderate length for variables. Most names should be between 2 and 12 letters long. 9. Use underscores to make compound names easier to read: tot vol or total_volumn is clearer than totalvolumn
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