/* 5-2 * Tanel Toova * Koostada programm, mis kasutades funktsiooni ftell() väljastaks käsurealt * etteantud faili suuruse. Faili nime puudumine loetakse veaks */ #include FILE *fFile; int main(int argc, char **argv) { if(argc!=2){ //if there is improper number of cmd-line parameters fprintf(stderr,"Usage: %s \n", argv[0]); return(1); } fFile = fopen(argv[1],"r"); if(!fFile){ //if it's not possible to open file fprintf(stderr,"Error opening %s",argv[1]); return(2); } fseek(fFile, 0, SEEK_END); //go to end of file //give the size of file in bytes fprintf(stdout,"The size of %s is %d bytes\n",argv[1],ftell(fFile)); return(0); }