Each line of text file contains the name of a file found in the current
directory. Copy the file, removing from it the names of non-existing files, and for
each existing file, write down its size in bytes.
My code
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <io.h> int main (int argc, char * argv[]) { FILE *myFile, *newFile, *tmpFile; char *mas; char nameFile[100]; char i; int sizeFile; if (argc != 2) { printf ("Some arguments are skipped\n"); exit (1); } if ((myFile = fopen (argv[1], "r+")) == NULL) { printf ("Can't open %s\n", argv[1]); exit (1); } newFile = fopen("new.txt", "r+"); //fscanf (myFile, "%s", nameFile); mas = fgets(nameFile,100,myFile); if (!mas) printf("\n End file or error \n"); else { tmpFile = fopen("\"" nameFile "\"","rb"); printf("%s", nameFile); fseek(tmpFile,0,SEEK_END); sizeFile = ftell(tmpFile); fseek(tmpFile,0,SEEK_SET); fprintf(newFile, "File name %s File name %d", nameFile, sizeFile); } return 0; }
help please !
test.txt :
test.c
test.h



LinkBack URL
About LinkBacks



