hello
can any body help me reading and writing structures to files
any sort of help is welcomed
plz
Printable View
hello
can any body help me reading and writing structures to files
any sort of help is welcomed
plz
So what have you actually tried to do so far?
You know about fread() and fwrite()?
according to the man page of fread
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
DESCRIPTION
The function fread reads nmemb elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.
The function fwrite writes nmemb elements of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr.
now the stream interface both in the fread and fwrite is a file pointer so can i use it for fifos
let us suppose that we have a custom structure
struct temp;
now i want to read data from a fifo fifo1 and write it in the temp structure
how to do it
So you tried to read the manual basically
How about
FILE *fp = fopen( "myfifio", "w" );
fwrite ( &temp, sizeof(temp), 1, fp );