I'm having a hard time finding my segmentation faults. Can anyone help me out please?
Code:
#include <stdlib.h>
#include <strings.h>
#include <stdio.h>
typedef struct proc_struct proc_struct;
typedef struct proc_struct * proc_ptr;
proc_ptr ReadyList[6];
struct proc_struct {
proc_ptr next_proc_ptr;
char name[10];
int priority;
};
void enqueue(proc_ptr *front, proc_ptr ptr){
if(*front == NULL)
*front = ptr;
else
{
proc_ptr p;
for(p = *front; p != NULL; p = p->next_proc_ptr){}
p = ptr;
}
}
proc_ptr dequeue(proc_ptr *front){
if(*front == NULL)
{
return NULL;
}
else
{
proc_ptr value = *front;
*front = (*front)->next_proc_ptr;
return value;
}
}
main()
{
int i;
for(i = 0; i < 6; i++)
ReadyList[i] = NULL;
proc_struct a,b;
strcpy(a.name, "hello");
strcpy(b.name, "bye");
a.priority = 1;
b.priority = 1;
a.next_proc_ptr = NULL;
b.next_proc_ptr = NULL;
enqueue( &ReadyList[1], &a );
enqueue( &ReadyList[1], &b );
printf(" ReadyList[1] contains %s \n", ReadyList[1]->name);
printf(" ReadyList[1]'s next contains %s \n", ReadyList[1]->next_proc_ptr->name);
//printf("%s\n",dequeue(&ReadyList[1])->name);
}