On Feb 27, 11:46 am, "chamois" <laurentpa...@yahoo.frwrote:
Hello,
I am migrating a program from Visual C++ 6 to Visual C++ 7.1.
When I run the exe file, the behavior is different because of the
qsort function.
Indeed I have some data which are identical for my comparison
function, but they aren't sorted on the same way depending on the
version of the compiler.
This should not be a surprise to you. qsort does not specify an order
for elements that compare equal.
>
It is not a disastrous problem but I would like to know if there is a
way to have an identical behaviour.
Probably not if you insist on using qsort. But since you are in a C++
forum, I should mention that std::stable_sort gives a "deterministic"
sort every time. It will likely differ from your current qsort result,
but the result on the two platforms will be identical.
You really should give up qsort, by the way. It is only useful for POD
and it is likely quite a bit slower than std::sort.
/Peter