Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Qsort - Sort array of strings (http://www.go4expert.com/forums/qsort-sort-array-strings-t15083/)

parthipanvelu 11Nov2008 11:45

Qsort - Sort array of strings
 
Hi , Can any one help me in this regard?

below is the code snippet I used to sort an array of strings

Code:

int cstring_cmp(const void *a, const void *b)
 {
  const char **ia = (const char **)a;
  const char **ib = (const char **)b;
  return strcmp(*ia, *ib);
  /* strcmp functions works exactly as expected from
  comparison function */
 }
 int removeDuplicates(int count,int k)
 {
  int i=0,j=0;
  char All[150][20];
  int y=1;
 
 
  if(count==0)
  {
  return 0;
  }
 
  for(i;i<count;i++)
  {
            if(k==1)//if the Non-Html is GIF
          {
                  sprintf(All[i],"{GIF_%d}",(i+1));//Save the "GIF" elements in "ALL[i]" array
          }
 
  }
        qsort(All, 150, 20, cstring_cmp);
 
  for(i;i<count;i++)
  {
  if(strcmp(All[i],All[i+1])==0)
  {
  }
  else
    y++;
  }
  return y;
 
 }


over her i am capturing some values in the loadrunner and storing them in a string array. i need these values to be sorted and retrieve the count of the unique values only. I am facing a Memory violation error in the line qsort. Can anyone help me solving this. the code is compiling without errors.


All times are GMT +5.5. The time now is 12:21.