In shmdt()
, no need to convert the pointer argument to void*
it will automatically take care of this .
Remove (void*)
from shmdt((void*) records[0]))
. It should be like this.
if ((error = shmdt(records[0]) ) == -1)
{
perror("Array detachment");
}
And it will work.
Also in shmat()
, on error it returns (void*) -1
so your comparison will give warning.
so do like this
if ((char *)records[0] == (void *)-1)
{
perror("Array Attachment");
}