0

Hi there,
Im new to this site, and I just have a question of something that I have been trying lately in the C language.

I need to put a whole array in a shared memory file (using POSIX).
I have no problems putting simple int* in shared memory. I do it this way:

int main(int argc, char* argv[]){
...
int *ptr;
...
int fd=shm_open("/shm12",O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);
...
ftruncate(fd,sizeof(int));
...
ptr=mmap(0,11*sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
...
}

Thats basically it, without error checking. What do I need to do to simillarly put an array, lets call it buffer[10], in shared memory?
Id apprecciate if anyone could help me.

2
Contributors
2
Replies
6
Views
9 Years
Discussion Span
Last Post by LightSystem
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.