I have done :
Why do i get a bus error when i initialise them?Code:#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include<time.h> #include <semaphore.h> #include <unistd.h> int main() { sem_t *sem; int shmid = shmget(4,3 * sizeof(sem_t),(IPC_CREAT | 0666)); sem[0] = shmat(shmid,NULL,0); /* then i initialise those three semaphores and i get a bus error */ sem_init(&sem[0][0]),1,1); sem_init(&sem[0][1]),1,0); sem_init(&sem[0][2]),1,0); }
Thanks, in advance!