Hi everybody!

I'm having some troubles with shared memory. What I want to achieve is to have a key-value storage (both key and value are strings) in shared memory (because of multiple processes accessing to the storage). What I do is the following:

Code:
char **kvStore;

[...]

shmem_kv = shmget(SHMEM_KV, sizeof(char *) * 200 * 2, IPC_CREAT | 0666);

//Attach to newly created memory
kvStore = shmat(shmem_kv, NULL, 0);
if (kvStore == (char *)(-1))
{
    fprintf(stderr, "Error allocating shared memory for kvStore\n");
}

for(int i = 0; i < 200 * 2; i++)
{
    shmem_entry = shmget(SHMEM_ENTRIES + i, sizeof(char) * 100, IPC_CREAT | 0666);
    kvStore[i] = shmat(shmem_entry, NULL, 0);

    if (kvStore[i] == (char *)(-1))
    {
        fprintf(stderr, "Error allocating shared memory for kvStore entry\n");
    }
}
Ideally, kvStore is the representation of such k-v storage. Instead of having a "real" matrix, I decided to put everything on a single array, then the first 200 entries are for keys, and the last 200 are for values (e.g. key position 5 => value position = 200 + 5). Am I doing something wrong in the declaration of the share memory? because when I decide to store stuff and, in a second moment, read it I am not able to read it anymore...