On Thu, May 7, 2009 at 5:34 AM, Robert Ryan <[email protected]> wrote:
> #include<iostream>
> using namespace std;
> #include <stdlib.h>
Decide whether you're using C or C++. If you're using C++, the header
you need is <cstdlib>, not <stdlib.h>
> struct node {
> int x;
> struct node *next;
> };
>
> int main()
> {
>
> struct node *root;
> //LL1.cpp:16: invalid conversion from `void*' to `node*'
> root = malloc( sizeof(struct node) );
Use new, not malloc() in C++. If you do use malloc() in C++, you need
to cast the return value.
> root->next = 0;
> root->x = 5;
>
> }
--
PJH
http://shabbleland.myminicity.com/com
http://www.chavgangs.com/register.php?referer=9375