CS2263/Final/FinalCode/io/iobinary.c
2023-05-22 23:28:51 -03:00

19 lines
413 B
C

#include <stdio.h>
int main(){
FILE *fp;
fp = fopen("iobinary.txt", "wb");
if(fp == NULL){
printf("Error opening file\n");
return 1;
}
int num = 0x12345678;
fwrite(&num, sizeof(int), 1, fp);
fclose(fp);
fp = fopen("iobinary.txt", "rb");
int num2;
fread(&num2, sizeof(int), 1, fp);
printf("%d\n", num2);
fclose(fp);
return 0;
}