Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!