Initial commit
This commit is contained in:
18
Final/FinalCode/io/iobinary.c
Normal file
18
Final/FinalCode/io/iobinary.c
Normal file
@ -0,0 +1,18 @@
|
||||
#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;
|
||||
}
|
19
Final/FinalCode/io/iotext.c
Normal file
19
Final/FinalCode/io/iotext.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
FILE *fp;
|
||||
fp = fopen("iotext.txt", "w");
|
||||
if (fp == NULL) {
|
||||
printf("Error opening file\n");
|
||||
return 1;
|
||||
}
|
||||
fprintf(fp, "CS2263!\n");
|
||||
fclose(fp);
|
||||
fp = fopen("iotext.txt", "r");
|
||||
char c;
|
||||
do {
|
||||
c = getc(fp);
|
||||
putchar(c);
|
||||
} while (c != EOF);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user