Skip to content

Commit 64e1067

Browse files
committed
modified: src/main.c
modified: src/r.c modified: src/w.c
1 parent 20c2539 commit 64e1067

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

c/fileio/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../include/head.h"
22
int main(){
3-
w();
4-
r();
3+
w("file.txt","this_is_an_apple");
4+
r("file.txt");
55
return 0;
66
}

c/fileio/src/r.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "../include/head.h"
2-
int r(){
2+
int r(const char* filename){
33
FILE *fp = fopen("file.txt","r");
4-
char a[10],b[10],c[10],d[10];
5-
fscanf(fp,"%s %s %s %s",a,b,c,d);
6-
printf("%s %s %s %s\n",a,b,c,d);
4+
char a[100];
5+
fscanf(fp,"%s",a);
6+
printf("%s",a);
77
fclose(fp);
88
return 0;
99
}

c/fileio/src/w.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "../include/head.h"
2-
int w(){
2+
int w(const char* filename,const char* string){
33
FILE *fp;
4-
fp = fopen("file.txt","w");
5-
fprintf(fp,"this is an %s\n","apple");
4+
fp = fopen(filename,"w");
5+
fprintf(fp,"%s",string);
66
fclose(fp);
77
return 0;
88
}

0 commit comments

Comments
 (0)