I want to create a pointer to an array of pointers (with 10 pointers in the array), then I want to give a pointer a value.
This is what I have so far:
char **arraypointer = calloc (10, sizeof (char*));
arraypointer = "string"
arraypointer->string = "this";
arraypointer->number = 3;
struct mystruct* pointer = calloc(N, sizeof(struct mystruct)); pointer.string = "this"; //notice . instead of -> ^ pointer.number = 3; ^
char **arraypointer = calloc (10, sizeof (char*)); arraypointer = "string";
These two lines are perfectly fine. You'd get a segfault(Undefined behavior, actually) if you tried to do something like
arraypointer = 's';
Also, you'd get in trouble if you did
because you haven't actually allocated any memory that
arraypointer[i] point to