Code:
PCB *pcb; <--- This is wrong
pcb->priority=0; //Error here
by declaring pcb as a *pcb, you only created a 4 byte pointer to a PCB struct, and since you did not assign the pointer to point to a valid struct object, you'll probably get error especialy in run time.
If you wish to use the pointer, you'll need to assign it to point to somewhere, the following will work:
Code:
PCB MyPCB;
PCB *pcb;
pcb = &MyPCB;
pcb->priority = 0;
You can also initialise the entire MyPCB to 0 with memset:
Code:
PCB MyPCB;
memset((void *)&MyPCB, 0, sizeof(MyPCB)); <-- Makesure that MyPCB is not a pointer