Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Help needed

This topic is 5575 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was writing a sorting function the way qsort was on some old compilers. I does a selection sort. For some strange reason, it does not work. v is a pointer to the vector to be sorted. nv is the number of elements to be sorted dimel is the dimension of one element Fc is the function that compares two elements TFComp2 is defined as: typedef int (* TFComp2)(const void *, const void *); int Sortare(void *v, size_t nv, size_t dimel, TFComp2 Fc) { char* i=CP(v); char* isel,* count; char* n=nv*dimel+i; char* buffer = CP(malloc(dimel)); if (buffer==NULL) return 0; while(ii) { memcpy(buffer, isel, dimel); memcpy(isel, i, dimel); memcpy(i, buffer, dimel); } i+=dimel; } return 0; } Could someone please explain me WHY it does not work? I''m kindof under pressure here, so help is appreciated. Saru

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!