hello
can any body help me reading and writing structures to files
any sort of help is welcomed
plz
hello
can any body help me reading and writing structures to files
any sort of help is welcomed
plz
/*****
One can't let go and still win
******/
So what have you actually tried to do so far?
You know about fread() and fwrite()?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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
/*****
One can't let go and still win
******/
So you tried to read the manual basically
How about
FILE *fp = fopen( "myfifio", "w" );
fwrite ( &temp, sizeof(temp), 1, fp );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.