Let's say I have the following structs:

```
// structures
typedef struct student {
    char *name;
    int  id;
    struct clist *courses;
} student;

typedef struct course {
    char *title;
    int  number;
    struct slist *students;
} course;

typedef struct slist {
    student      *info;
    struct slist *next;
} slist;

typedef struct clist {
    course       *info;
    struct clist *next;
} clist;

```

Let's assume that `clist` and `slist` have content inside.
Now for my question:
I am having a problem iterating the `clist` and `slist` structs (linked lists).
I made the next function for adding course to student courses:

```
void reg_student(slist *students,clist *courses,int id,int number){
  clist* Cpointer=courses;
  slist* Spointer=student;

  //finding course location
  for(;Cpointer->info->number!=number;Cpointer=Cpointer->next);

  //find student location
  for(;Spointer->info->id != id;Spointer=Spointer->next);

  //adding course to student courses list
  Spointer->info->courses=Cpointer;
  Spointer->info->courses->next->NULL;
  return;
}

```

When it start searching for the location of the course, it removes all the courses before him.
for example lets say I am looking for course number '555' and I have 3 courses in the list of courses - ('111,'222,'333') , once the function finish only '333' is in the list.

How can I iterate the struct without removing things inside?