title: Using multidymentional array in c store a line from the user and return the words in the line in decending order according to the word length
body: <p>Write a program which read a line from user until user press enter key ('\n'). Store all the words of a line
  into multidimensional dynamic array. Then pass this array to a function SortString(), which will sort all the
  words by word length i.e. longest word will be placed at a first index, then second longest word will be
  placed at a second index and so on. Finally return the sorted list of words back to main function, where
  all the words will be printed onto the screen as one word per line. Assume that the line contains all unique
  words.</p>
  <p>I have written some code here but I am having problems with how to sort the lengths of the words in the line and print them in descending order.</p>
  <pre><code>#include&lt;stdlib.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  main(){
      char string[50];
      int i, l;
      char *ptr, *p;
      printf(&quot;Enter the string: &quot;);
      gets(string);
      l=strlen(string);
      ptr=(char*)malloc((l+1)*sizeof(char));
      p=ptr;
      if(ptr==NULL){
          printf(&quot;\n Enter out of memory&quot;);
          exit(0);
      }
      for(i=0;i&lt;l;i++){
          *ptr=string[i];
          ptr++;
      }
      *ptr='\0';  
  }
  </code></pre>