Content deleted Content added
Rashadmlkv (talk | contribs) →Functions: Added content Tags: Mobile edit Mobile web edit |
It is not an error to read less than 5 bytes, so handle it gracefully |
||
Line 247:
int main(void) {
char buffer[5];
size_t len;
FILE* fp = fopen("myfile", "rb");
Line 254 ⟶ 255:
}
if ((len = fread(buffer, 1, 5, fp)) <
fclose(fp);
fputs("An error occurred while reading the file.\n", stderr);
Line 263 ⟶ 264:
printf("The bytes read were: ");
for (int i = 0; i <
printf("%02X ", buffer[i]);
}
|