M
Morris Keesan
Here is my latest attempt and error message.
#include <stdio.h>
int main(void) {
struct tree *p,*tp;
tp=insert(p,2,"name",3,"color");
printf("%s\n",(struct tree)tp);
}
a.c: In function `main':
a.c:5: warning: assignment makes pointer from integer without a cast
a.c:6: conversion to non-scalar type requested
There's no declaration of insert() in scope, so it's implicitly
declared to be a function returning int. At line 5, the compiler
is complaining because you're attempting to assign that int to a pointer.
Line 6 is total garbage. You're trying to take a pointer-to-struct,
cast it to a struct (this is the "conversion to non-scalar type"),
and then pass that struct to printf, where printf is expecting a
pointer-to-char, i.e. a string. If you want to print some string
member of the struct that tp might point to, then it would be something
like
printf("%s\n", tp->stringmember);
where stringmember is a member of struct tree.