|
typedef struct{}*poly; |
type568
Member #8,381
March 2007
|
I have gotten a problem, I want to swap structs, fast. (swap their places..)
The sorting, of course returns an error... i tried various combinations of *, and & and again, of course none helped me. Would you do please.. ?
|
X-G
Member #856
December 2000
|
... why would + and - work on a struct without those operators defined? Hell, what do you even expect it to do in the first place? Copy them as usual. Use a temporary copy if you'd like. -- |
kazzmir
Member #1,786
December 2001
|
First of all it looks like you are trying to sort these things so use qsort. Then don't make an array of structs, make an array of pointers to structs.
|
Matt Smith
Member #783
November 2000
|
Quote: Then don't make an array of structs, make an array of pointers to structs. No harm in using qsort on an array of structs, if the structs aren't enormous. |
type568
Member #8,381
March 2007
|
Structs are small, but might be a huge amount... Thanks kazzmir. I expected to swap pointers.. While there are no pointers EDIT: here how I made it though:
|
BAF
Member #2,981
December 2002
|
That is horrible. It's much easier, and better looking, if you just swap the elements the proper way, instead of using that extra array. |
type568
Member #8,381
March 2007
|
I dunno how much slower is it.. And probably the best way is **poly.. But it would be faster than swapping contents of the struct for sure.
|
|