How do you detach an array of strings from shared memory? C
- by Tim
I have:
int array_id;
char* records[10];
// get the shared segment
if ((array_id = shmget(IPC_PRIVATE, 1, 0666)) == -1) {
perror("Array Creating");
}
// attach
records[0] = (char*) shmat(array_id, (void*)0, 0);
if ((int) *records == -1) {
perror("Array Attachment");
}
which works fine, but when i try and detach i get an "invalid argument" error.
// detach
int error;
if( (error = shmdt((void*) records[0])) == -1) {
perror(array detachment);
}
any ideas? thank you