TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken H
NA
646
360.7k
sort of structure in c language
Dec 12 2013 4:26 AM
hello friend,
I encountered a problem: memory error occurred sorting structure.
My code is as follows:
void bubble_sort(struct Student *h)
// On the "Total" to sort.
{
struct Student *temp=h,*p;
int swapped;
int T_stu_id;
char T_name[15];
float T_score[CURRICULUM_MAX];
float T_Average;
float T_Total;
/*
if(h!=NULL){
do
{
swapped=0;
temp=h;
for (;temp->next!=NULL;)
{
p=temp->next;
if(temp->Total>p->Total){
T_stu_id=temp->stu_id;
strcpy(T_name,temp->name);
T_score[CURRICULUM_MAX]=temp->score[CURRICULUM_MAX];
T_Average=temp->Average;
T_Total=temp->Total;
temp->stu_id=p->stu_id;
strcpy(temp->name,p->name);
temp->score[CURRICULUM_MAX]=p->score[CURRICULUM_MAX];
temp->Average=p->Average;
temp->Total=p->Total;
p->stu_id=T_stu_id;
strcpy(p->name,T_name);
p->score[CURRICULUM_MAX]=T_score[CURRICULUM_MAX];
p->Average=T_Average;
p->Total=T_Total;
swapped=1;
}
temp=temp->next;
}
} while (swapped);
}
print(h);
*/
}
I do not want to use the above algorithm, because it will change the original position.
Note: Do not exchange element, they only change the pointer field.
Annex has my complete code.
Thank very much. :)
Attachment:
sims_demo.rar
Reply
Answers (
8
)
An error occurred while initializing data members.
Double precision data type conversion in c language