#include <stdio.h>
int main() {
FILE *out = fopen("file.txt", "w+");
FILE *in = fopen("file.txt", "r");
int temp = 0;
for ( int i = 0; i < 15; i++ ) {
fprintf(out, "%d\n", i);// filliing the file with values as we have created it and it contains EOF only
}
for ( int j = 0; j < 15; j++ ) {
fscanf(in, "%d", temp);
printf("%d\n", temp);//showing the contents
}
if( remove( "file.txt" ) != 0 ) {
perror( "Error deleting file" );
} else {
puts( "File successfully deleted" );
}
return 0;
}
Comments
Leave a comment