1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How sort and do a list after giving struct?

Discussion in 'C' started by DOSASIS09, Feb 4, 2010.

  1. DOSASIS09

    DOSASIS09 New Member

    Joined:
    Feb 5, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello, im not an inexpert guy programming and I need to do an application in c, that I declare using a structure 3or4 structures predefined. After that I need to sort this 3 or 4 strucutres “tasks†depends on the parameter of the priority in each structure. I would like to read the structures and then do a sort list only writting the ID of the task, but depending on the PRIORITY of each task. I don’t know how many pointers I should use.I understand how to sort a list with a array of an integer values…but I don’t know how to do this. Objective is sort at the begging that tasks, but later function sort should be able to add more times same task, during program execution. Any help, is welcome, I am lost...Thanks just for read it.
    File.h
    typedef struct Task_Struct
    {
    unsigned char TASK_ID;
    unsigned char PRIORITY;
    unsigned char PREEMPTION;
    unsigned char STATUS;
    struct Task_Struct *next;
    };


    File.c
    #define NR_TASKS 3
    struct Task_Struct Task[NR_TASKS]

    define_t{

    Task[0].TASK_ID=1;
    Task[0].PRIORITY=3;
    Task[0].PREEMPTION=1;
    Task[0].STATUS=0;

    Task[1].TASK_ID=2;
    Task[1].PRIORITY=2;
    Task[1].PREEMPTION=1;
    Task[1].STATUS=0;

    Task[2].TASK_ID=3;
    Task[2].PRIORITY=4;
    Task[2].PREEMPTION=1;
    Task[2].STATUS=0;
    }
     

Share This Page