Originally Posted by
itsinthecompute
I am toying with putting pointers to strings inside a double array.
What do you mean by that?
Frankly, this:
Code:
printf("0 %p %f\n", &(*(buf + 0)), *(buf + 0));
printf("1 %p %f\n", &(*(buf + 1)), *(buf + 1));
printf("2 %p %f\n", &(*(buf + 2)), *(buf + 2));
memcpy(&(*(buf + 1)), &s, sizeof(char *));
looks like a complicated way of writing:
Code:
printf("0 %p %f\n", (void*)&buf[0], buf[0]);
printf("1 %p %f\n", (void*)&buf[1], buf[1]);
printf("2 %p %f\n", (void*)&buf[2], buf[2]);
memcpy(&buf[1], &s, sizeof(char *));
or equivalently:
Code:
printf("0 %p %f\n", (void*)(buf + 0), buf[0]);
printf("1 %p %f\n", (void*)(buf + 1), buf[1]);
printf("2 %p %f\n", (void*)(buf + 2), buf[2]);
memcpy(buf + 1, &s, sizeof(char *));
But what on earth are you trying to do with that memcpy?
Originally Posted by
itsinthecompute
1)
I would expect row 37 to be equivalent to row 36.
But they are not equivalent, row 37 generates a compiler error and warning:
test.c:37:5: error: cannot convert to a pointer type
test.c:37:5: warning: reading through null pointer (argument 2)
What does this mean?
What is the type of buf[1]?