
24-01-2009, 23:45
|
|
|
|
חבר מתאריך: 01.07.03
הודעות: 2,466
|
|
|
איבוד כתובת
ערב טוב...
אני מנסה לבנות פה תוכנית כולשהי תוך כדי שימוש בהקצאה דינאמית למטריצה.. הבעיה היא שברגע שאני שולח את המטריצה לפונקציה שמבצעת השמות למינהם... הכתובת נאבדת אשמח לעזרה
קוד:
typedef struct
{
unsigned grade_sem_a; //
unsigned grade_sem_b; //
}Grades;
typedef struct
{
unsigned long id; //
char full_name[LEN]; // ( )
char address[LEN]; //
Grades g; //
}Student;
הגדרה במMAIN ...
קוד:
Student **students;
students = (Student**)malloc(matELE*sizeof(Student*));
for(i=0;i<matELE;i++)
students[i] = (Student*)malloc(2*sizeof(Student));
merge_arrays(A,arrELE,mat,matELE,(Student*)student s);
כאשר ARRELE ו MATELE שניהן מערכים מאותו טיפוס STUDENT
קוד:
void merge_arrays(Student *array1, int size1,Student *array2, int size2, Student *array3)
{
int i=0, j=0;
Student *tmp = &(array3[0]);
printf("%p",&(array3[0]));
while((i<size1)&&(j<size2))
{
if(array1[i].g.grade_sem_b<array2[j].g.grade_sem_b)
array3[i+j]=array1[i++];
else
array3[i+j]=array2[j++];
}
if(i==size1)
for( ; j<size2; j++)
array3[i+j]=array2[j];
else j==size2;
for( ; i<size1; i++)
array3[i+j]=array1[i];
}
_____________________________________
_
אני הלוחם של היום והלויס ליין של המחר
נערך לאחרונה ע"י macox בתאריך 24-01-2009 בשעה 23:48.
|