Hi there,
I'm using a large structure, and I want to sort it by one of its members, a double variable.
This is the code I would like to implement:
These are the definitions I'm using,Code://RMSD Sort, this one works OK. qsort(outlib, structs_len, sizeof(res), struct_cmp_by_rmsd); //then the structure needs to be re-sorted qsort(outlib, structs_len, sizeof(res), struct_cmp_by_Model);
after compiling, I get this error:Code:int struct_cmp_by_rmsd(const void *a, const void *b) { res *ia = (res *)a; res *ib = (res *)b; return (int)(1000000.f*ia->rmsd_ext - 1000000.f*ib->rmsd_ext); /* float comparison: returns negative if b > a and positive if a > b. We multiplied result by 10000.0 to preserve decimal fraction */ } int struct_cmp_by_Model(const void *a, const void *b) { res *ia = (res *)a; res *ib = (res *)b; return (int *) ( ia->numModel - ib->numModel ); }
I could not get this one to work, any help would be really appreciated.Code:sort_structures.h: In function `int struct_cmp_by_Model(const void*, const void*)': sort_structures.h:19: warning: cast to pointer from integer of different size sort_structures.h:19: error: invalid conversion from `int*' to `int'
Thanks in advance,
Juan Pablo



LinkBack URL
About LinkBacks


