Binary file read-write function __ function

Source: Internet
Author: User


* * Dstbuf:storage location for data.
 * Size:item size in bytes. * Startele:which is the "start" element to read.
 (counts from 0) * count:maximum number of items to be read.
 * Filename:name of the file to be read. */int Abanfread (void *dstbuf, size_t size, long Startele, size_t count, Char *filename) {FILE *file = fopen (FileName,
  "RB");
  Fseek (file, startele*size, Seek_set);
  Fread (dstbuf, size, count, file);
  fclose (file);
return 0;
 }/* Srcbuf:pointer to is written.
 * Size:item size in bytes. * Startele:which is the ' start element position to be written.
 (Starts from 0) * count:maximum number of the items to be written.
 * Filename:name of the file to be read. */int abanfwrite (const void *SRCBUF, size_t size, long Startele, size_t count, Char *filename) {FILE *file = fopen (fil
  ENAME, "WB");
  Fseek (file, startele*size, Seek_set);
  Fwrite (srcbuf, size, count, file);
  fclose (file); Return 0; }

These two functions can be used to read and write binary data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.