the employees must be registered in alphabetical order, but i don't know how...........

struct EMP
{
    int  empno;
    char empName[MAX];
        char designation[MAX];
        struct EMP *next;
};




struct EMP* insert(struct EMP *front, int id, char name[], char desg[])
{
    struct EMP *newnode;


    newnode = (struct EMP*) malloc(sizeof(struct EMP));


    if (newnode == NULL)
    {
          printf("\nAllocation failed\n");
        exit(2);
    }
    newnode->empno = id;
    strcpy(newnode->empName, name);
    strcpy(newnode->designation, desg);
    newnode->next = front;
    front = newnode;
    return(front);
}                                /*End of insert() */

You can find the first employee in the list that is greater than that you want to insert, and insert before it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.