Determine if file write out is true c -
is there way find out if file write occurred in c. i'm supposed return 0 if wrote file , -1 if nothing written.
if you're using fwrite()
, example, return code number of items written.
similarly, fprintf()
returns number of characters written.
so can examine return code figure out if written, like:
if (fprintf (fh, "val=%d\n", value) == 0) return -1; return 0;
or:
if (fwrite (buffer, sizeof(something), 7, fh) == 0) return -1; return 0;
keep in mind you're asking nothing/something indication , means partial or complete success. if want know how much of requested written, hat's tiny bit more complex.
Comments
Post a Comment