I am writing a simple program for managing the final grades of students. The program first read original data from a file called "final.txt", and create a linked list to store the imfornation in memory.

The format of the orginal data is "Class_Character Seat_number Computer_grades Laboratory_grades".

There is only data for one student in every line.
For example,the content of "final.txt" may looks like:

C 9 67 72
B 36 98 60
A 41 23 56
B 51 52 33
C 8 45 12

After I finished creating the Linked List, I want to use "Selection Sort" to sort the data based on the students' classes and the sum of math and english grades. The result of the sort may looks like:

[IMG]http://img37.imageshack.us/img37/9837/89640759.jpg[/IMG]

The following is the code which I wrote:

#include<stdio.h>
#include<stdlib.h>
struct student
{
    int com,com_use; //[com:Computer_grades] [com_use:Laboratory_grades]
    int num,total; // [num:Seat_number] [total:the sum of math and english grades]
    struct student * next;
};
struct classes
{
    char t; // [t:Class_Character]
    struct student * point;
    struct classes * next;
};
void sl_sort(struct classes **,struct student **); // The function of "Selection Sort"
int main()
{
    FILE *data;
    char temp;
    int first=1;
    int num_t,com_t,com_u_t;
    int stu_count=0;
    struct student *stu_head,*stu_pt,*stu_pre,*stu_cur;
    struct classes *cla_head,*cla_pt,*cla_pre,*cla_cur;
    stu_head=NULL;
    cla_head=NULL;
    data=fopen("final.txt","r");
    while ((fscanf(data,"%c %d %d %d\n",&temp,&num_t,&com_t,&com_u_t)) != EOF)
    {
        stu_pt=(struct student *)malloc(sizeof(struct student));
        stu_pt->num=num_t;
        stu_pt->com=com_t;
        stu_pt->com_use=com_u_t;
        stu_pt->total=com_t+com_u_t;
        stu_pt->next=NULL;
        if (first == 1)
        {
            stu_head=stu_pt;
            cla_head=(struct classes *)malloc(sizeof(struct classes));
            cla_head->t=temp;
            cla_head->point=stu_head;
            cla_head->next=NULL;
            first=0;
        }
        else
        {
            cla_cur=cla_head;
            while (cla_cur != NULL)
            {
                if (cla_cur->t == temp)
                {
                    break;
                }
                cla_cur=cla_cur->next;
            }
            if (cla_cur == NULL)
            {
                cla_pt=(struct classes *)malloc(sizeof(struct classes));
                cla_pt->t=temp;
                cla_pt->point=stu_pt;
                cla_pt->next=NULL;
                cla_pre=cla_head;
                while (cla_pre->next != NULL)
                {
                    cla_pre=cla_pre->next;
                }
                cla_pre->next=cla_pt;
            }
            else
            {
                stu_pre=cla_cur->point;
                while (stu_pre->next != NULL)
                {
                    stu_pre=stu_pre->next;
                }
                stu_pre->next=stu_pt;
            }
        }
    }
    fclose(data);
    sl_sort(&cla_head,&stu_head);
    return 0;
}
void sl_sort(struct classes **cla_head,struct student **stu_head)
{
    struct classes *cla_temp,*cla_cur,*cla_pre,*cla_start,*cla_add_at;
    int cla_start_count=0,i;
    cla_start=*cla_head;
    while (1)
    {
        if (cla_start_count != 0)
        {
            cla_start=*cla_head;
            for (i=cla_start_count;i>0;i--)
            {
                cla_start=cla_start->next;
            }
        }
        if (cla_start->next = NULL)
        {
            break;
        }
        cla_cur=cla_start;
        cla_temp=cla_start;
        while (cla_cur != NULL)
        {
            if (cla_cur->t < cla_temp->t)
            {
                cla_temp=cla_cur;
            }
            cla_cur=cla_cur->next;
        }
        cla_pre=*cla_head;
        while (cla_pre->next != cla_temp)
        {
            cla_pre=cla_pre->next;
        }
        cla_pre->next=cla_temp->next;
        if (cla_start_count != 0)
        {
            cla_add_at=*cla_head;
            while (cla_add_at->next != cla_start)
            {
                cla_add_at=cla_add_at->next;
            }
            cla_temp->next=cla_pre;
            cla_add_at->next=cla_temp;
        }
        else
        {
            cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

There's no error messages while compiling. But when I tried to run the program, I got an error message from Windows, it said "grades.exe has encountered a problem and needs to close. We are sorry for the inconvenience." I don't know where the problem is (maybe the sort or the double pointers), could you help me to correct the code? Thanks for any reply.

Errors I found :

int cla_start_count=0,i;
cla_start=*cla_head;
while (1)
{
        if (cla_start_count != 0)
        {
             cla_start=*cla_head;
             for (i=cla_start_count;i>0;i--)
             {
                 cla_start=cla_start->next;
             }
       }
if (cla_start->next = NULL) // Error 
{
     break;
}

Error : Assignment operator instead of comparison operator.You need to use == and you have used =.

Apart from this the code runs fine without error but you have just sorted and left it as such. You haven't written the code for printing the sorted list.

Thanks. After I corrected the "==", the code became

#include<stdio.h>
#include<stdlib.h>
struct student
{
    int com,com_use; //[com:Computer_grades] [com_use:Laboratory_grades]
    int num,total; // [num:Seat_number] [total:the sum of math and english grades]
    struct student * next;
};
struct classes
{
    char t; // [t:Class_Character]
    struct student * point;
    struct classes * next;
};
void sl_sort(struct classes **,struct student **); // The function of "Selection Sort"
int main()
{
    FILE *data;
    char temp;
    int first=1;
    int num_t,com_t,com_u_t;
    int stu_count=0;
    struct student *stu_head,*stu_pt,*stu_pre,*stu_cur;
    struct classes *cla_head,*cla_pt,*cla_pre,*cla_cur;
    stu_head=NULL;
    cla_head=NULL;
    data=fopen("final.txt","r");
    while ((fscanf(data,"%c %d %d %d\n",&temp,&num_t,&com_t,&com_u_t)) != EOF)
    {
        stu_pt=(struct student *)malloc(sizeof(struct student));
        stu_pt->num=num_t;
        stu_pt->com=com_t;
        stu_pt->com_use=com_u_t;
        stu_pt->total=com_t+com_u_t;
        stu_pt->next=NULL;
        if (first == 1)
        {
            stu_head=stu_pt;
            cla_head=(struct classes *)malloc(sizeof(struct classes));
            cla_head->t=temp;
            cla_head->point=stu_head;
            cla_head->next=NULL;
            first=0;
        }
        else
        {
            cla_cur=cla_head;
            while (cla_cur != NULL)
            {
                if (cla_cur->t == temp)
                {
                    break;
                }
                cla_cur=cla_cur->next;
            }
            if (cla_cur == NULL)
            {
                cla_pt=(struct classes *)malloc(sizeof(struct classes));
                cla_pt->t=temp;
                cla_pt->point=stu_pt;
                cla_pt->next=NULL;
                cla_pre=cla_head;
                while (cla_pre->next != NULL)
                {
                    cla_pre=cla_pre->next;
                }
                cla_pre->next=cla_pt;
            }
            else
            {
                stu_pre=cla_cur->point;
                while (stu_pre->next != NULL)
                {
                    stu_pre=stu_pre->next;
                }
                stu_pre->next=stu_pt;
            }
        }
    }
    fclose(data);
    sl_sort(&cla_head,&stu_head);
    cla_cur=cla_head; // print the linked list whose head is called "cla_head"
    while(cla_cur != NULL)
    {
        printf("%c\n",cla_cur->t);
        cla_cur=cla_cur->next;
    }
    return 0;
}
void sl_sort(struct classes **cla_head,struct student **stu_head)
{
    struct classes *cla_temp,*cla_cur,*cla_pre,*cla_start,*cla_add_at;
    int cla_start_count=0,i;
    cla_start=*cla_head;
    while (1)
    {
        if (cla_start_count != 0)
        {
            cla_start=*cla_head;
            for (i=cla_start_count;i>0;i--)
            {
                cla_start=cla_start->next;
            }
        }
        if (cla_start->next == NULL)
        {
            break;
        }
        cla_cur=cla_start;
        cla_temp=cla_start;
        while (cla_cur != NULL)
        {
            if (cla_cur->t < cla_temp->t)
            {
                cla_temp=cla_cur;
            }
            cla_cur=cla_cur->next;
        }
        cla_pre=*cla_head;
        while (cla_pre->next != cla_temp)
        {
            cla_pre=cla_pre->next;
        }
        cla_pre->next=cla_temp->next;
        if (cla_start_count != 0)
        {
            cla_add_at=*cla_head;
            while (cla_add_at->next != cla_start)
            {
                cla_add_at=cla_add_at->next;
            }
            cla_temp->next=cla_pre;
            cla_add_at->next=cla_temp;
        }
        else
        {
            cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

(I want to figure out the sort of the classes first, so I didn't write the sort for the sum of math and english grades yet.)

The result is right when I use the data

C 9 67 72
B 36 98 60
A 41 23 56
B 51 52 33
C 8 45 12

in "final.txt" file, but when I tried to modify the content of it to:

C 9 67 72
B 36 98 60
A 41 23 56
B 51 52 33
C 8 45 12
K 5 30 55
G 98 33 12
D 45 95 90
A 46 78 11

The message "grades.exe has encountered a problem and needs to close. We are sorry for the inconvenience." appears again. What's wrong with the code? Did I write the Selection Sort function (sl_sort) wrongly?

Errors (from line 119) :

cla_pre=*cla_head;
while (cla_pre->next != cla_temp) //Error 1
{
cla_pre=cla_pre->next;
}
cla_pre->next=cla_temp->next;
if (cla_start_count != 0)
{
cla_add_at=*cla_head;
while (cla_add_at->next != cla_start)
{
cla_add_at=cla_add_at->next; //Error 2
}
cla_temp->next=cla_pre; //Error 3
cla_add_at->next=cla_temp;
}
else
{
cla_temp->next=*cla_head;
*cla_head=cla_temp;
}
cla_start_count=cla_start_count+1;
}
}

There are corrections needed after line 119.It should be like this (you can just delete everything from 119 onwards including 119 and add the below code):

cla_pre=*cla_head;       //Error 1handling start
        if(cla_temp!=cla_pre)
        {
            while (cla_pre->next != cla_temp)
            {
                cla_pre=cla_pre->next;
            }
            cla_pre->next=cla_temp->next;
        }
        else
        {
            cla_start_count=cla_start_count+1;
            continue;
        }                                                // Error 1 handling end
   
        if (cla_start_count != 0)                    
        {
             cla_add_at=*cla_head;
             for(i=cla_start_count;i>1;i--)          //Error 2 handling start
             {
                 cla_add_at=cla_add_at->next;
             }                                                           //Error 2 handling end
             cla_temp->next=cla_add_at->next;     // Error 3 handled 
             cla_add_at->next=cla_temp;
        }
        else
        {
             cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

Error 1:
You didn't handle the condition where temp could be the first node,so in that case pre would start from head and never get a condition where in pre->next=temp because in this case pre=temp.So segmentation fault.
Error 2:
Here you weren't moving cla_add_at in right way atleast not the correct number of times.
Error 3:
You need to insert temp node here.But look at what you were doing before this.You were doing something totally nonsense.

With these errors corrected its giving the right output.

After I read the code you provided, I finally found some errors. But I don't understand why (at line 19 of your code)

for(i=cla_start_count;i>1;i--)   //Error 2 handling start

should the "for" statement have the condition "i>1". Why can't it end at "i=0"?

No what I have written is wright because assume the following condition :

1 -> 2 -> 3 -> D -> E -> .....

Now if you assume cla_start_count = 3 that is if first three nodes are in their correct positions and if you want to add the temp node in your hand after the third node then
head = 1
shift 1 : 1 -> 2
shift 2 : 2 -> 3

Now you are in the correct node to add the temp node.
Now
temp->link=3->link;
3->link=temp;
will cause the link to be
1 -> 2 -> 3 -> temp -> D -> E -> .....

So if you observed properly if cla_start_count is equal to n then you just need to move cla_add_at n-1 times from the start as cla_add_at=cla_add_at->link;

So for i>1 is perfectly right... Got it ? ;)

Okay. I understand the shifting. But I have another question about the code.
After I corrected the errors you told me, the code became:

#include<stdio.h>
#include<stdlib.h>
struct student
{
    int com,com_use; //[com:Computer_grades] [com_use:Laboratory_grades]
    int num,total; // [num:Seat_number] [total:the sum of math and english grades]
    struct student * next;
};
struct classes
{
    char t; // [t:Class_Character]
    struct student * point;
    struct classes * next;
};
void sl_sort(struct classes **,struct student **); // The function of "Selection Sort"
int main()
{
    FILE *data;
    char temp;
    int first=1;
    int num_t,com_t,com_u_t;
    int stu_count=0;
    struct student *stu_head,*stu_pt,*stu_pre,*stu_cur;
    struct classes *cla_head,*cla_pt,*cla_pre,*cla_cur;
    stu_head=NULL;
    cla_head=NULL;
    data=fopen("final.txt","r");
    while ((fscanf(data,"%c %d %d %d\n",&temp,&num_t,&com_t,&com_u_t)) != EOF)
    {
        stu_pt=(struct student *)malloc(sizeof(struct student));
        stu_pt->num=num_t;
        stu_pt->com=com_t;
        stu_pt->com_use=com_u_t;
        stu_pt->total=com_t+com_u_t;
        stu_pt->next=NULL;
        if (first == 1)
        {
            stu_head=stu_pt;
            cla_head=(struct classes *)malloc(sizeof(struct classes));
            cla_head->t=temp;
            cla_head->point=stu_head;
            cla_head->next=NULL;
            first=0;
        }
        else
        {
            cla_cur=cla_head;
            while (cla_cur != NULL)
            {
                if (cla_cur->t == temp)
                {
                    break;
                }
                cla_cur=cla_cur->next;
            }
            if (cla_cur == NULL)
            {
                cla_pt=(struct classes *)malloc(sizeof(struct classes));
                cla_pt->t=temp;
                cla_pt->point=stu_pt;
                cla_pt->next=NULL;
                cla_pre=cla_head;
                while (cla_pre->next != NULL)
                {
                    cla_pre=cla_pre->next;
                }
                cla_pre->next=cla_pt;
            }
            else
            {
                stu_pre=cla_cur->point;
                while (stu_pre->next != NULL)
                {
                    stu_pre=stu_pre->next;
                }
                stu_pre->next=stu_pt;
            }
        }
    }
    fclose(data);
    sl_sort(&cla_head,&stu_head);
    cla_cur=cla_head; // print the linked list whose head is called "cla_head"
    while (cla_cur != NULL)
    {
        printf("%c\n",cla_cur->t);
        cla_cur=cla_cur->next;
    }
    return 0;
}
void sl_sort(struct classes **cla_head,struct student **stu_head)
{
    struct classes *cla_temp,*cla_cur,*cla_pre,*cla_start,*cla_add_at;
    int cla_start_count=0,i;
    cla_start=*cla_head;
    while (1)
    {
        if (cla_start_count != 0)
        {
            cla_start=*cla_head;
            for (i=cla_start_count;i>0;i--)
            {
                cla_start=cla_start->next;
            }
        }
        if (cla_start->next == NULL)
        {
            break;
        }
        cla_cur=cla_start;
        cla_temp=cla_start;
        while (cla_cur != NULL)
        {
            if (cla_cur->t < cla_temp->t)
            {
                cla_temp=cla_cur;
            }
            cla_cur=cla_cur->next;
        }
        cla_pre=*cla_head;
        if (cla_temp!=cla_pre)
        {
            while (cla_pre->next != cla_temp)
            {
                cla_pre=cla_pre->next;
            }
            cla_pre->next=cla_temp->next;
        }
        else
        {
            cla_start_count=cla_start_count+1;
            continue;
        }
        if (cla_start_count != 0)
        {
            cla_add_at=*cla_head;
            for (i=cla_start_count;i>1;i--)
            {
                cla_add_at=cla_add_at->next;
            }
            cla_temp->next=cla_add_at->next;
            cla_add_at->next=cla_temp;
        }
        else
        {
            cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

In the "sl_sort" function, the "cla_pre" seems useless after I modified line 140 and line 141. So I tried to delete the contents which related to "cla_pre" (from line 119 to line 132) and the code became:

#include<stdio.h>
#include<stdlib.h>
struct student
{
    int com,com_use; //[com:Computer_grades] [com_use:Laboratory_grades]
    int num,total; // [num:Seat_number] [total:the sum of math and english grades]
    struct student * next;
};
struct classes
{
    char t; // [t:Class_Character]
    struct student * point;
    struct classes * next;
};
void sl_sort(struct classes **,struct student **); // The function of "Selection Sort"
int main()
{
    FILE *data;
    char temp;
    int first=1;
    int num_t,com_t,com_u_t;
    int stu_count=0;
    struct student *stu_head,*stu_pt,*stu_pre,*stu_cur;
    struct classes *cla_head,*cla_pt,*cla_pre,*cla_cur;
    stu_head=NULL;
    cla_head=NULL;
    data=fopen("final.txt","r");
    while ((fscanf(data,"%c %d %d %d\n",&temp,&num_t,&com_t,&com_u_t)) != EOF)
    {
        stu_pt=(struct student *)malloc(sizeof(struct student));
        stu_pt->num=num_t;
        stu_pt->com=com_t;
        stu_pt->com_use=com_u_t;
        stu_pt->total=com_t+com_u_t;
        stu_pt->next=NULL;
        if (first == 1)
        {
            stu_head=stu_pt;
            cla_head=(struct classes *)malloc(sizeof(struct classes));
            cla_head->t=temp;
            cla_head->point=stu_head;
            cla_head->next=NULL;
            first=0;
        }
        else
        {
            cla_cur=cla_head;
            while (cla_cur != NULL)
            {
                if (cla_cur->t == temp)
                {
                    break;
                }
                cla_cur=cla_cur->next;
            }
            if (cla_cur == NULL)
            {
                cla_pt=(struct classes *)malloc(sizeof(struct classes));
                cla_pt->t=temp;
                cla_pt->point=stu_pt;
                cla_pt->next=NULL;
                cla_pre=cla_head;
                while (cla_pre->next != NULL)
                {
                    cla_pre=cla_pre->next;
                }
                cla_pre->next=cla_pt;
            }
            else
            {
                stu_pre=cla_cur->point;
                while (stu_pre->next != NULL)
                {
                    stu_pre=stu_pre->next;
                }
                stu_pre->next=stu_pt;
            }
        }
    }
    fclose(data);
    sl_sort(&cla_head,&stu_head);
    cla_cur=cla_head; // print the linked list whose head is called "cla_head"
    while (cla_cur != NULL)
    {
        printf("%c\n",cla_cur->t);
        cla_cur=cla_cur->next;
    }
    return 0;
}
void sl_sort(struct classes **cla_head,struct student **stu_head)
{
    struct classes *cla_temp,*cla_cur,*cla_pre,*cla_start,*cla_add_at;
    int cla_start_count=0,i;
    cla_start=*cla_head;
    while (1)
    {
        if (cla_start_count != 0)
        {
            cla_start=*cla_head;
            for (i=cla_start_count;i>0;i--)
            {
                cla_start=cla_start->next;
            }
        }
        if (cla_start->next == NULL)
        {
            break;
        }
        cla_cur=cla_start;
        cla_temp=cla_start;
        while (cla_cur != NULL)
        {
            if (cla_cur->t < cla_temp->t)
            {
                cla_temp=cla_cur;
            }
            cla_cur=cla_cur->next;
        }
        if (cla_start_count != 0)
        {
            cla_add_at=*cla_head;
            for (i=cla_start_count;i>1;i--)
            {
                cla_add_at=cla_add_at->next;
            }
            cla_temp->next=cla_add_at->next;
            cla_add_at->next=cla_temp;
        }
        else
        {
            cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

But the program starts to run infinitely! What's wrong with the code? Is there any method for solving the problem without "cla_pre"?

Look the first thing you need to do is to relax and look at your own code more care fully ok. The code I posted in my post #2 was just minute alterations to your code with few corrections and I had mentioned all the reasons of error too.

Now who told you that cla_pre is useless.It has its meaning which you had given in the first code and it has retained its meaning.cla_pre has meaning when temp points to all nodes from the second node till the last node. It looses its meaning only when tem is pointing to the first node,ie the first node is the smallest element and temp and cla_pre both point to it.Perhaps you didn't read my post #2 properly. All the mistakes have been rectified then itself.

Well this is your complete code with corrections applied and it doesn't give any errors.
(gives right output for the second set of records you posted too)

#include<stdio.h>
#include<stdlib.h>
struct student
{
    int com,com_use; //[com:Computer_grades] [com_use:Laboratory_grades]
    int num,total; // [num:Seat_number] [total:the sum of math and english grades]
    struct student * next;
};
struct classes
{
    char t; // [t:Class_Character]
    struct student * point;
    struct classes * next;
};
void sl_sort(struct classes **,struct student **); // The function of "Selection Sort"
int main()
{
    FILE *data;
    char temp;
    int first=1;
    int num_t,com_t,com_u_t;
    int stu_count=0;
    struct student *stu_head,*stu_pt,*stu_pre,*stu_cur;
    struct classes *cla_head,*cla_pt,*cla_pre,*cla_cur;
    stu_head=NULL;
    cla_head=NULL;
    data=fopen("final.txt","r");
    while ((fscanf(data,"%c %d %d %d\n",&temp,&num_t,&com_t,&com_u_t)) != EOF)
    {
        stu_pt=(struct student *)malloc(sizeof(struct student));
        stu_pt->num=num_t;
        stu_pt->com=com_t;
        stu_pt->com_use=com_u_t;
        stu_pt->total=com_t+com_u_t;
        stu_pt->next=NULL;
        if (first == 1)
        {
            stu_head=stu_pt;
            cla_head=(struct classes *)malloc(sizeof(struct classes));
            cla_head->t=temp;
            cla_head->point=stu_head;
            cla_head->next=NULL;
            first=0;
        }
else
        {
            cla_cur=cla_head;
            while (cla_cur != NULL)
            {
                if (cla_cur->t == temp)
                {
                    break;
                }
                cla_cur=cla_cur->next;
            }
            if (cla_cur == NULL)
            {
                cla_pt=(struct classes *)malloc(sizeof(struct classes));
                cla_pt->t=temp;
                cla_pt->point=stu_pt;
                cla_pt->next=NULL;
                cla_pre=cla_head;
                while (cla_pre->next != NULL)
                {
                    cla_pre=cla_pre->next;
                }
                cla_pre->next=cla_pt;
            }
            else
            {
                stu_pre=cla_cur->point;
                while (stu_pre->next != NULL)
                {
                    stu_pre=stu_pre->next;
                }
                stu_pre->next=stu_pt;
            }
        }
    }
    fclose(data);
    sl_sort(&cla_head,&stu_head);
    cla_cur=cla_head; // print the linked list whose head is called "cla_head"
    while(cla_cur != NULL)
    {
        printf("%c\n",cla_cur->t);
        cla_cur=cla_cur->next;
    }
    return 0;
}
void sl_sort(struct classes **cla_head,struct student **stu_head)
{
    struct classes *cla_temp,*cla_cur,*cla_pre,*cla_start,*cla_add_at;
    int cla_start_count=0,i;
    cla_start=*cla_head;
    while (1)
    {
        if (cla_start_count != 0)
        {
            cla_start=*cla_head;
            for (i=cla_start_count;i>0;i--)
            {
                cla_start=cla_start->next;
            }
        }
        if (cla_start->next == NULL)
        {
            break;
        }
        cla_cur=cla_start;
        cla_temp=cla_start;
        while (cla_cur != NULL)
        {
            if (cla_cur->t < cla_temp->t)
            {
                cla_temp=cla_cur;
            }
            cla_cur=cla_cur->next;
        }
cla_pre=*cla_head;
        if(cla_temp!=cla_pre)
        {
            while (cla_pre->next != cla_temp)
            {
                cla_pre=cla_pre->next;
            }
            cla_pre->next=cla_temp->next;
        }
        else
        {
            cla_start_count=cla_start_count+1;
            continue;
        }
        if (cla_start_count != 0)
        {
             cla_add_at=*cla_head;
             for(i=cla_start_count;i>1;i--)
             {
                 cla_add_at=cla_add_at->next;
             }
             cla_temp->next=cla_add_at->next;
             cla_add_at->next=cla_temp;
        }
        else
        {
             cla_temp->next=*cla_head;
            *cla_head=cla_temp;
        }
        cla_start_count=cla_start_count+1;
    }
}

This is what i said earlier too.That the code you posted in your second post was perfectly right till line 118 then after it I told you to paste the code I put up in my second post(which was nothing but your code with errors rectified.)

And ya Don't paste the whole codes every time and waste the community space just because it is provided for free.Do it only when absolutely necessary or make it as an attachment. Its better if you just paste in the segment with fault. Now you don't even need to do that i suppose ;)

This article has been dead for over six months. Start a new discussion instead.