Are you sure you are needing to use realloc, is this some realloc exercise? As calling this over and over for each new student roll to be entered is costly.
I would prefer you change over to strictly using an array for this and is much faster to insert.
Remove your realloc and any malloc calls, you do no need them then!Code:StdInfo students[10]; ... do { printf ("Enter Roll of Student %d :\t", i); scanf ("%d", &(students[i++].roll)); printf ("\n\nEnter another ? (1/0):\t"); scanf ("%d", &s); } while (s == 1);
Then do double check that they have been inserted try something like this:
Code:int z = 0; for (; z < i; z++) { printf ("Students rolls are: student %d, roll = %d\n", z, students[z].roll); }



LinkBack URL
About LinkBacks




), I'll refrain from trying to help you there.