purpose: Understand the command line argument, its usage, and applications Instruction:

1 answer below »



purpose:


Understand the command line argument, its usage, and applications





Instruction:




Write a program, named
sortlist,
that reads two to fourintegersfrom the command linearguments
and returns thesorted list of theintegers on the standard output screen. You need to use
strtol()
function to convert a string to a long integer.For instance,



>sortit3 5




>The sorted listis 3, 5.



>sortit 3 5 7



>The sorted listis 3, 5, 7.



>sortit 4 0 9 89



>The sorted list is 0,4, 9, 89



>sortit 1 p 9



>sortit: invalid input p.



>sortit



>usage: sortitnum1num2num3!




Things to submit:









1. The source code of a c file



2. Screenshots(20%) thatshowsuccessfulexecution of the testing cases such as 1. invalid input, 2. wrong usage (not enough arguments)



3. You need to use a command-line argument method. (30%)



4. Include format error checking, and input validation is required. (10%)



5. Follow the coding format as the above example.






PLEASE READ THE INSTRUCTION VERY CAREFULLY AND IF ANY PROBLEM PERSIT DON’T HESITATE TO INFORM ME. PLEASE AND THANK YOU.

Answered Same DayFeb 10, 2021

Answer To: purpose: Understand the command line argument, its usage, and applications Instruction:

Rohith answered on Feb 12 2021
137 Votes
50578/.DS_Store
__MACOSX/50578/._.DS_Store
50578/sortlist
50578/sortlist.c
#include
#
include
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
int main(int argc, char const *argv[])
{
int size = argc - 2;
int arr[size];
char *ptr;
long ret;
int temp;
if (argc > 6 || argc <= 3)
{
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here