IN PROGRAMMING LANGUAGE C
-I am trying to alphbetize a string in descending orto
EX
INPUT: B C D A
OUTPUT:
D
C
B
A
#include
#include
#include
#include
int main(int argc, char*argv[])
{
       int MAX = 100000;
       int i =0;
       int k =0;
       int j =0;
       char array[MAX];
       char split[] = \",.-!?()0123456789\";
       int n = 0;
       char second[MAX];
       printf(\"Please enter ina String: \");
       //String input
       fgets(array,MAX,stdin);
       char **first=(char**)malloc(sizeof(char*));
       char *token =strtok(array,split);
       while(token!=NULL)
       {
               k = strlen(token);
               first=(char **)realloc(first,(n+1)*sizeof(char));
               first[n] = (char *)malloc((k+1)*sizeof(char));
               memcpy(first[n],token,k*sizeof(char));
               token = strtok(NULL,split);
               n++;
       }
       second =sortedArray(first,n);
       for(i =0;i       {
        printf(\"%s\",second[i]);
       }
       return 0;
}
char *sortedArray(char *sortRay[], int size)
{
       int i =0;
       int j =0;
       char temp[300];
       for(i =0; i       {
         for(j =i +1;j          {
            if(strcmp(sortRay[i],sortRay[j])>0)
           {
            strcpy(temp,sortRay[i]);
            strcpy(sortRay[i],sortRay[j]);
            strcpy(sortRay[j],temp);
           }
          }
       }
       return sortRay;
}