Problem with semaphores

Hello,
I was doing an exercise of semaphores and shared memory, namely the barbers:
-B number of barbers
-S number of chairs
-C number of customers.
I have done already and I compiled the code, but when run I get an error segment. Can not be and it took several days.
If anyone sees the error and I indicated I would make a great favor.
Thanks

You can tell what line the segmentation fault occurs on by compiling with -ggdb, then running with gdb. i.e.

gdb
run ./filename
(text informing you the program crashed)
bt f

Thanks