swapping section and credit numbers along with course name

How can I also make section and credits switch with course_name, there's an error when I try to print out courses

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  class1* head = student_list[stu_index].p_class_from_student;
         class1* tmp = head;
         while(tmp != NULL){
                        class1 *A, *B;
            A = head; 
            B = A->p_class;
			
            while(B != NULL){
               int result = strcmp (A->course_name, B->course_name);           
               //If value is less than 0 then perform swap function to rearrange                
                if (result > 0){
                     char tmp[7];
					 int section=1;
					 int credit=1;
					 
					 
                                      while(strcpy(tmp, A->course_name)&&strcpy(A->course_name, B->course_name)&&strcpy(B->course_name, tmp))
									  {
										  
										 int x = section;
                                      section = section+1;
									 int f=section+1;
                                        f = x;

										 int y=credit;
										 credit=credit+1;
										 int s=credit+1;
										 s=y;
									  }
                                      

                          

                }
                                A = A->p_class;
                                B = A->p_class;
                    
Last edited on
Topic archived. No new replies allowed.