assignment makes pointer from integer without a cast
- by mrblippy
hi, i am trying to make a linked list and create some methods. but i am getting the error
assignment makes pointer from integer without a cast.
#include <stdio.h>
#include <stdlib.h>
#include "students.h"
node_ptr create(void)
{
node_ptr students = (node_ptr) malloc(sizeof(struct node));
students->ID = 0;
students->name = NULL;
students->next = NULL;
return students;
}
void insert_in_order(int n, node_ptr list)
{
node_ptr before = list;
node_ptr new_node = (node_ptr) malloc(sizeof(struct node));
new_node->ID = n;//error is here i think
while(before->next && (before->next->ID < n))
{
before = before->next;
}
new_node->next = before->next;
before->next = new_node;
}