I am trying to create a piece of shared memory to split an array, here is my example:
int main(){
key_t key;
int shm_id;
int arr[10];
key=ftok("~/.bashrc",1);
shm_id = shmget(key, 10*sizeof(int), 0666 | IPC_CREAT);
arr = (int*)shmat(shm_id, NULL, 0);
arr[0]=101;
printf("%d\n",arr[0]);
}
When compiling, I get the following error:
error: incompatible types in assignment of ‘int*’ to ‘int [10]’
What is wrong with my assignment?
source
share