This repository has been archived on 2025-12-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2024-09-20 14:17:13 +03:00

27 lines
507 B
C

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i, nr;
FILE *fptr;
fptr = fopen("test.bin", "wb"); // w for read, b for binary
// Write file
for (i = 0; i < 10; i++)
fwrite(&i, sizeof(int), 1, fptr);
fclose(fptr);
printf("File written!\n");
// Read file
fptr = fopen("test.bin", "rb"); // r for read, b for binary
while (fread(&nr, sizeof(int), 1, fptr) != 0)
printf("%d,", nr);
printf("\n");
fclose(fptr);
return (0);
}