Hi
I've spent a long time on the web & reading books trying to find out how to do this for myself.
No luck, there's a lot of stuff refering to using pointer to a function but very little on returning a pointer and it doesn't appear to do what I want it to
.
So I'm hopping someone knows how to return a pointer
I want to call a procedure and for that procedure to return a pointer.
The procedure builds a linked list of a struct
Code:
struct1 read()
{
// init stuff
struct1 *start_pointer;
loop till end
get data
create new record for list
insert into list
if this is the first recored, set a pointer to the start of the list
//
return start_pointer
}
main
{
//init stuff
struct1 *ptr;
ptr = read(); //I want ptr to point to the start of the linked list created in read
// other stuff
}
It looks like I'm passing pointers to pointers, but I get an error -
<cannot convert from 'struct netData *' to 'const struct netData'>
Prefixing the return parameter with a * gives error on the calling line
<binary '=' : no operator defined which takes a right-hand operand of type 'struct netData'>
while prefixing with & gives -
<cannot convert from 'struct netData ** ' to 'const struct netData'>
I also get errors prefixing both ptr and the calling read
- yes I am clutching at straws.
I have tried using this, but also get errors here
Gratefull for any help given