I want (or need) to do something along the lines of
char **my_array = malloc(1000*64);
strcpy(arr[0], "test");
While I know that arr[0] isn't pointing to a separate piece of allocated memory, I thought one should be able to copy a string into it like this (yet it segs). This works
arr[0] = "test";
However that is not going to work, for my actual goal is to do this in shared memory.
shm_array = shmget(IPC_PRIVATE, 1000 * 64, IPC_CREAT | 0644);
my_array = (char**) shmat(shm_array, (void**)0, 0);
Actually my question could be rephrased to: "How do you create an array of strings in shared memory?". I tried creating 1000 separate "string" shared memory segments, but apart of that it did not work it also seems wrong. Moreover, I thought one should simply be able to write into a big shared memory segment using relative pointer offsets.