File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ FILE *file_open(char *name, char *mode)
168168
169169int file_close (FILE * file_p )
170170{
171- if (file_flush (file_p ) == EOF )
171+ if (file_p -> flag . _WRITE == 1 && file_flush (file_p ) == EOF )
172172 {
173173 return EOF ;
174174 }
@@ -179,7 +179,7 @@ int file_close(FILE *file_p)
179179 file_p -> counter = 0 ;
180180 close (file_p -> file_descriptor );
181181
182- return NULL ;
182+ return 0 ;
183183}
184184
185185int main (void )
@@ -204,6 +204,7 @@ int main(void)
204204 {
205205 putc (c , file_out_p );
206206 }
207+ file_close (file_in_p );
207208 file_close (file_out_p );
208209
209210 return EXIT_SUCCESS ;
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ FILE *file_open(char *name, char *mode)
168168
169169int file_close (FILE * file_p )
170170{
171- if (file_flush (file_p ) == EOF )
171+ if (file_p -> flag . _WRITE == 1 && file_flush (file_p ) == EOF )
172172 {
173173 return EOF ;
174174 }
@@ -179,7 +179,7 @@ int file_close(FILE *file_p)
179179 file_p -> counter = 0 ;
180180 close (file_p -> file_descriptor );
181181
182- return NULL ;
182+ return 0 ;
183183}
184184
185185int file_seek (FILE * file_p , long offset , int whence )
@@ -227,6 +227,7 @@ int main(void)
227227 {
228228 putc (c , file_out_p );
229229 }
230+ file_close (file_in_p );
230231 file_close (file_out_p );
231232
232233 return EXIT_SUCCESS ;
You can’t perform that action at this time.
0 commit comments