<div dir="ltr">Nevermind, solved it :)<div><br></div><div>I moved the strcmp into a separate function and provided that to quicksort and it appears to work. My compare</div><div><br></div><div><div>int cmp (char **str1, char **str2)</div>
<div>{</div><div>  return strcmp(*str1,*str2);</div><div>}</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 21, 2013 at 2:47 PM, Tejas Nadkarni <span dir="ltr">&lt;<a href="mailto:tnadkarn@stevens.edu" target="_blank">tnadkarn@stevens.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It might be a stupid mistake but I&#39;m puzzled. I&#39;m trying to sort an array of strings which is the file listing for a directory. Based on manpages, online docs and forums I&#39;m using the write code and it executes without errors. However the resulting array is not sorted properly. qsort is a void function so no way to tell if it&#39;s erroring out during the sort.<div>

<br></div><div>Here&#39;s my call</div><div><br></div><div><span style="white-space:pre-wrap">        </span>qsort(input, size, sizeof(char*), (int(*)(const void*, const void*))strcmp);<br></div><div><br></div><div>input is my char* array, size is the # of elements in input, sizeof(char*) size of each element, the last parameter is casting strcmp for const void since that&#39;s what&#39;s needed by qsort. I&#39;ve also tried writing my own compare function with strcmp in it and I get same results.</div>

<div><br></div><div>It&#39;s quite puzzling.</div><div><br></div><div>Here&#39;s an example output before and after qsort by running ls on /sys on Ubuntu so it&#39;s doing something but almost like it&#39;s not completing the sort?? Any ideas?</div>

<div><br></div><div><div>$ ./ls /sys</div><div>fs </div><div>devices </div><div>dev </div><div>bus </div><div>class </div><div>firmware </div><div>hypervisor </div><div>kernel </div><div>power </div><div>module </div><div>

block </div><div><br></div><div><br></div><div>firmware </div><div>hypervisor </div><div>kernel </div><div>power </div><div>fs </div><div>module </div><div>devices </div><div>block </div><div>dev </div><div>bus </div><div>

class </div></div><div><br></div><div><br></div><div><br></div></div>
</blockquote></div><br></div>