Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the following code so If no command line arguments are given, sort the hardcoded test data as before. If there are command line arguments,

Modify the following code so If no command line arguments are given, sort the hardcoded test data as before.
If there are command line arguments, convert them to integers and use them values to
initialize the data array to be sorted. #include
#include
int main(int argc, char * argv[])
{
int i;
fprintf(stderr, "I was invoked with the command: %s
", argv[0]);
if (argc >1){
fprintf(stderr, "The command line arguments are:
");
for(i =1; i < argc; i++){
fprintf(stderr," argv[%d](as string): %s
"
"(as int): %d
"
"(as int in hex): %X
",
i, argv[i], atoi(argv[i]), atoi(argv[i]));
}
} else {
fprintf(stderr, "There were no command line arguments.
");
}
exit(0);
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions