Hi geeks!, since I started programming I have never used qsort() for sorting. I also tried to consult books but, 'little or no success!'.

Can anyone who know better help me to understand qsort() function.
Please do it with an example!

Happy forever even faced with c++!

Recommended Answers

All 4 Replies

Wot a quick reply! Thanks jencas I 'l have a look at it. One more question, Can I sort a listbox containing strings?

How about loading all the strings to a vector and sorting that vector?

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()

    vector<string> allStrings;

    sort(allStrings.begin(), allStrings.end());

    for (int i = 0; i < allStrings.size(); i++)
        cout << allStrings[i] << "\n";

    return 0;
Member Avatar

niek_e already gave you the right hint. I would do it the same way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.