P
Paminu
In the following code I am trying to initialize a pointer that is located in
a struct.
#include <stdlib.h>
#include <stdio.h>
#define KIDS 4
typedef struct test
{
void *content;
struct test_ *bob;
} test_;
int main(void)
{
test_ *tt, *array;
tt =(test_ *) malloc(sizeof(test_));
array = (test_ *)malloc(sizeof(test_ *)*KIDS);
tt->bob = array;
return 0;
}
I would like the pointer called "bob" in struct "test_" to point to the same
thing that "array" points to. Actually I would like the to copy "array" to
"bob". When I compile the above code I get the error:
test2.c: In function 'main':
test2.c:21: warning: assignment from incompatible pointer type
how do I initialize the bob pointer with the array pointer?
a struct.
#include <stdlib.h>
#include <stdio.h>
#define KIDS 4
typedef struct test
{
void *content;
struct test_ *bob;
} test_;
int main(void)
{
test_ *tt, *array;
tt =(test_ *) malloc(sizeof(test_));
array = (test_ *)malloc(sizeof(test_ *)*KIDS);
tt->bob = array;
return 0;
}
I would like the pointer called "bob" in struct "test_" to point to the same
thing that "array" points to. Actually I would like the to copy "array" to
"bob". When I compile the above code I get the error:
test2.c: In function 'main':
test2.c:21: warning: assignment from incompatible pointer type
how do I initialize the bob pointer with the array pointer?