Question: C LANGUAGE Write a command line utility that takes any number of words on the command line and prints the words out, sorted according to
C LANGUAGE
Write a command line utility that takes any number of words on the command line and prints the words out, sorted according to the character at a certain specified position, which should also be specified via the command line.
If two strings have the same character at the position of interest, their order does not matter.
To solve the problem, you are ONLY allowed to use pointers throughout the program.
You are NOT allowed to use any arrays. In other words, you will not have a single bracket in your program.
Template.C
/** * A command line utility that takes any number of words on the command * line and prints the words out. The first argument is a character index * by which to sort the words. */ #include#include void swap_words(char** words, int index_word_1, int index_word_2); int is_bigger(char* pointer_word_1, char* pointer_word_2, int position); char** sort(int number_words, char** words, int position); int main(int argc, char **argv) { if(argc < 3) { printf("Insufficient arguments "); return -1; } int position = atoi(*(argv+1)); sort(argc-2, argv+2, position); for(int i=2; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
