i want to perform posix shared memory ipc
here is the reader program
/
Code:
//////////////////////////////////////////////////// #include <sys/mman.h> #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main(int argc,char** argv) { int i,fd; struct stat st; unsigned char c,*ptr; if(argc!=2) { fprintf(stdout,"usage: shm_read <name>"); } fd=shm_open(argv[1],0,0777); fstat(fd,&st); ptr=mmap(NULL,4096,PROT_READ,MAP_SHARED,fd,0); close(fd); for(i=0;i<st.st_size;i++) { fprintf(stdout,"%d",*ptr++); } exit(0); } ///////////////////////////////////////////////////code ends
when i compile it i get the error
shm_read.c: In function `main':
shm_read.c:8: storage size of `st' isn't known(soory for the code misformatting)
help plz