Jak porównać ciąg C ++ za pomocą qsort w c?

Próbowałem nauczyć się funkcji qsort biblioteki cstdlib. To jest dostarczane nawet wc++. Ale nie rozumiem, jak ich używać do sortowaniac++ smyczki. Nie jestem pewien, jakie powinny być parametry dlasizeof() operator i czy mójcompare_str kod jest prawidłowy. Próbowałem tego kodu:

    #include<iostream>
    #include<cstdlib>
    using namespace std;
    #include<string>

    int compare_str( const void *a, const void *b){
       string  obj = (const char*)a;
       string obj1 = (const char*)b;
       return obj.compare(obj1);
    }
    int main(){
        string obj[4] = {"fine", "ppoq", "tri", "get"};
        qsort(obj, 4, sizeof(obj[0].length()), compare_str);
        for( int i=0; i<4; i++)
            cout<<obj[i]<<endl;
        return 0;
    }

Moje wyjście było:

ppoq
tri
get
fine

Nie jestem w stanie dostrzec błędu. Proszę pomóż.

questionAnswers(6)

yourAnswerToTheQuestion