I need help to assign two array of stractures to each other?!!
Many Thanks
I need help to assign two array of stractures to each other?!!
Many Thanks
post your code - we cannot read your mind, so show us what you have already.
~/
Thanks for you reply, actually I need to use qsort() function. I got a global array of structure as follows:
RECORD record[MAX_NO_ITEM]; //global- kept without change
and I have a function that I need to declare another array of structures to send it as an arrgument to qsort() as follows:
void sort_record()
({
RECORD sorted_rec[MAX_NO_ITEM];// here is a new declaration of array of strutures
// here I need to assign record to sort_record ?????
//It is silly to try: sorted_rec[] = record[]
qsort(sorted_rec, no_of_items, sizeof(RECORD), compare_stock);
//dispaly the sorted items by using sorted_rec
})
the reason for declaring a new array of stracture "sorted_rec" , as you may getting the idea, is to keep the content of "record" un changed.Code:hello
Use a for loop and do
sorted_rec[i] = record[i];
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Can I use pointers to do the job.
Thanks
What do you mean - "use pointers"
It will be a lot quicker to sort an array of pointers than sort an array of records, if that's what you mean.
If you mean rewrite the loop using pointer notation, then no it wont be any quicker.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.