Copy a file block per block in C
问题 I'm trying to divide a file into an x ammount of blocks of size y (in bytes), so that I can copy each block individually. How can I do that? 回答1: Try using fread char buffer[ysize]; fread(buffer, ysize, 1, fp); Each time you read ysize bytes in buffer from the file. 回答2: Some struct stat structures have additional members in them that prove useful when copying files: st_blksize The optimal I/O block size for the file. st_blocks The actual number of blocks allocated for the file in (check