Initialize a 1D or 2D array in shared memory

I am trying to initialize a 2D char array of strings into POSIX shared memory to be shared between 3 other processes. There are plenty of tutorials on how to use a pointer to share a single string or an integer between processes, but I could find no examples on how to initialize 1D or 2D arrays using

mmap()

. I have posted what I have so far below. It is the first program, which creates the shared memory object and initialize the array

char files[20][2][100]

with the value

files[0][0][0] = '\0'

.

What is the proper method to initialize and share an array in C?

For context, I coded a simple version of this project (at the suggestion of helpful S.O. gurus) which does not use shared memory and combines all 4 processes (separated by

/**********/

) into one. It's below.

I've asked a similar question involving structs in a previous post, but I was required to use a multidimensional array instead for my project. Any insights on that answer would be helpful HERE.

there are faster ways to perform the initialization to '\0'
for instance:

memset( ptr, '\0', SIZE );

There is no need for the local variable: 'files'

However, since a number of different processes can access the
shared memory at the same time,
the code needs a named semaphore that all the processes use
so only one process is accessing the shared memory at
any one time, to avoid 'race' conditions.
here is a good discussion, with example usage, for semaphores
http://www.cs.cf.ac.uk/Dave/C/node26.html
the code should be checking for errors, something like this:
( of course, using your own variable names )