assignment makes pointer from integer without a cast

Posted by mrblippy on Stack Overflow See other posts from Stack Overflow or by mrblippy
Published on 2010-04-21T10:21:28Z Indexed on 2010/04/21 10:23 UTC
Read the original article Hit count: 179

Filed under:

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;
}

© Stack Overflow or respective owner

Related posts about c