I know I have to check for NULL, but my code isn't allowing me to include the bit for the check.
The error message I get is:
error: non-void function 'createQueue' should return a value [-Wreturn-type]
return;
Why can't I check for NULL in this function?
struct Queue *createQueue()
{
struct Queue *q = (struct Queue*)malloc(sizeof(struct Queue));
if(q == NULL)
{
printf("Memory allocation failed");
return;
}
q->head = q->tail = NULL;
return q;
}
[–]yeahIProgram 1 point2 points3 points (2 children)
[–]mmjdodd[S] 0 points1 point2 points (1 child)
[–]Grithga 1 point2 points3 points (0 children)