Pointer to an array of pointers.
Name:
Anonymous
2007-09-13 21:24
ID:Ly++VlgN
int lol = 3;
int *lol_ptr = &lol;
int *ptr_array;
ptr_array = malloc(sizeof(lol_ptr));
ptr_array[0] = lol_ptr;
printf("%d\n", (*(*ptr_array[0])));
gcc gives the following error:
error: invalid type argument of 'unary *'
Halp.
Name:
Anonymous
2007-09-13 21:35
ID:WydlcVYj
fag
Name:
Anonymous
2007-09-13 21:41
ID:Ly++VlgN
>>2
True.
Figured it out.
int **ptr_array;
Will cry less next time.
Name:
Anonymous
2007-09-13 21:56
ID:j06eg3jj
#include <stdio.h>
#define ARRAY_SIZE 1
int main()
{
int value = 3;
int *intPointer = NULL;
int **intPointerArray = NULL;
intPointer = &value;
intPointerArray = malloc(sizeof(int*) * ARRAY_SIZE);
intPointerArray[0] = intPointer;
printf("%i",*intPointerArray[0]);
getchar();
return 0;
}
THAT TASK WAS FUCKING TRIVIAL YOU STUPID RETARD
Name:
Anonymous
2007-09-13 22:01
ID:kB61fLc+
>>4
where is ARRAY_SIZE defined thouhg? :/
Name:
Anonymous
2007-09-13 22:02
ID:j06eg3jj
Name:
2010-10-23 19:04