Thanks for the tips quzah, I went with door number 4 and attempted to write my own function that would reverse my linked list. Its my first time doing this, this is what I wrote:
Code:
STUDENT* rev_list( STUDENT* stud ) {
STUDENT * ptr;
while( stud != NULL ) {
ptr = malloc(sizeof(STUDENT));
strcpy( (ptr -> name) , (stud -> name) );
(ptr -> ID) = (stud -> ID);
stud = stud -> studentPtr; /*Moves pointer stud to next
node in original list */
ptr -> studentPtr = rev_top;
rev_top = ptr;
}
}
where my struct data type student is this:
Code:
typedef struct student {
char name[11]; /* Students Name **************/
int ID; /* Student's ID number ********/
struct student* studentPtr; /* Pointer to next student ****/
} STUDENT;
I was wondering if I have created unneccassary garbage doing this? I think what I have done now is created to linked-lists (2 stacks) I don't think creating the reversed one affected my original one.... am I correct in thinking this?
Thank You