at the qsort function in c there is a functin pointer to the compare function, which actually sorts the data of the array given.
so inside that function i see:
if ( *(MyType*)a < *(MyType*)b ) return -1;
Well i understand a will casted to MyType* but what about the star after that on the very left? what is it doing?
Well, i guess this just dereference the pointer a?
thx.
/me
Well i understand a will casted to MyType* but what about the star after that on the very left? what is it doing?
So you know a
is a pointer and pointer holds some valid memory location the value stored in that memory location is fetched by using the *
operator which is called Dereferencing a pointer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.