Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this problem, the following C library functions can be used, but no others: printf, sprintf, strcmp, atoi, sizeof, malloc, and free. Write a program

For this problem, the following C library functions can be used, but no others: printf, sprintf, strcmp, atoi, sizeof, malloc, and free. Write a program that does the following:

  1. Takes the following command-line arguments from the user: a secret code, a first name, a last name, and one or more whole numbers.
  2. If the user doesn't give a sufficient number of command-line arguments, output "Invalid input" and terminate.
  3. If the user doesn't give the correct secret code, output "Incorrect secret code" and terminate. The correct secret code is: hHFmas. (Hint: strcmp returns 0 if the two string arguments match.)
  4. Store the first and last name in a string variable called fullName, with a space between the first and last name. (Hint: Use sprintf.)
  5. You must use malloc to allocate sufficient memory for the fullName variable, and deallocate that memory before program termination.
  6. Output fullName and the average of the numbers on the command line. The average must be accurate to 1 decimal place.
  7. The program must work for names of any length and an arbitrary amount of numbers on the command line.

Please help asap!

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Understand why customers complain.

Answered: 1 week ago