:'(
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++!

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

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

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

using namespace std;

int main()
{

    vector<string> allStrings;
    allStrings.push_back("bbb");
    allStrings.push_back("abb");
    allStrings.push_back("aaa");
    allStrings.push_back("aba");
    allStrings.push_back("aac");

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

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

    cin.get();
    return 0;
}
Member Avatar for jencas

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, networking, learning, and sharing knowledge.