Hello,
Any ideas what's wrong with this?:
I know you're not really supposed to put *'s in typedefs but I really want to just for this example.Code:typedef unsigned char * test; void init_test(test *t); void insert(test *t); void free_test(test *t); int main() { test t; init_test(&t); insert(&t); printf("%d\n", t[0]); free_test(&t); return 0; } void init_test(test *t) { *t = malloc(100 * sizeof(*t)); } void insert(test *t) { *t[0] = 200; *t[1] = 201; *t[2] = 202; *t[3] = 203; } void free_test(test *t) { free(*t); *t = NULL; }
The bus error is happening, I think, in the insert function.
Any suggestions much appreciated.