How to use qsort for an array of strings?

前端 未结 3 2018
傲寒
傲寒 2021-01-15 04:45
#include 
#include 
#include 

int sortstring(const void *str1, const void *str2) {
    const char *rec1 = str1;
    c         


        
3条回答
  •  [愿得一人]
    2021-01-15 05:45

    This line is incorrect.

        qsort(lines, 200, sizeof(char), sortstring);
    

    Change it to

        qsort(lines, 200, sizeof(char*), sortstring);
    

提交回复
热议问题