hi all,
i am running slackware linux and need to use some function that will
will enable me to write and read a STRUCT from a shared mem segment..
i am using open() , to open a file (and get the file descriptor fd returned), and then use mmap to get a void* file_memory pointer.
function fwrite() (from stdio.h) doesn't work cause it can write to a file (ie needs a FILE* nor a void* and casting in this case makes the executable crash), nor does write() (from unistd.h), ie the linux standard write function, that needs as input the file decriptor (int) fd instead of the (void*) file_memory pointer...
and i don't think i can use sprintf because it needs you to define the type of variable you are giving as an argument to it (%d for decimal, %f for float, %p for pointer, %s for string etc..) and i do not know how to 'define' the structure that i want to save... or am i wrong in thinking that and there is a type i can use to store my structure?
is there any other way?
thank you for your help
nass
Bookmarks