struct tnode
    int data;
    struct tnode* left;
    struct tnode* right;

struct tnode*talloc(int data)

    struct tnode*p=(struct tnode*) malloc(sizeof(struct tnode))
    if (p!=NULL)
    return p;

int main(){}

I am getting a [error: 'NULL' undeclared] error, Any help would be greatly appreciated.


struct tnode doesn't contain a member next

struct tnode*p=(struct tnode*) malloc(sizeof(struct tnode));

Missing semicolon. Casting the return of malloc is not recommended in C. Just include the header file stdlib.h

Try including the header file stdio.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.