Hello
I have a problem with files calculating....
I do the program but then it do chdir("..") and the you do system("dir.......") it start reading directoriesfrom the first but i want that it start reading in line which number belongs with how many time was doing cycle.
there is my program:
Code:#include <stdio.h> #include <dir.h> #include <direct.h> #include <dirent.h> #include <conio.h> #include <string.h> #include <stdlib.h> #include <io.h> #include <process.h> #include <dos.h> char kata[8]; struct ffblk ffblk; int taip; long kiek=0; int chdir (const char *kata); int kiekis (char *kata); int kiekis(char *kata) { FILE *f; if (chdir (kata) == 0){ taip = findfirst("*.*",&ffblk,0); while (!taip) {kiek=kiek+1; taip = findnext(&ffblk);}} FILE_SEEK system("dir/ad/b>temp.txt"); f = fopen ("temp.txt", "r"); while (fscanf(f,"%s",kata)!=EOF) { chdir (kata); if (chdir (kata) == 0){ taip = findfirst("*.*",&ffblk,0); while (!taip) {kiek=kiek+1; taip = findnext(&ffblk);}} system ("dir/ad/b > temp.txt"); if (fscanf(f,"%s",kata)==EOF) { chdir ("..");system ("dir/ad/b > temp.txt");} else kiekis (kata);} fclose (f); return (0);} int main() { int d; long kiek3=0,kiek2=0; FILE *ff; clrscr (); printf ("\nSet the disk where you want to calculate files\n"); scanf ("%d",&d); _chdrive (d); chdir ("\\"); if (_chdrive(d) == 0){ taip = findfirst("*.*",&ffblk,0); while (!taip) { kiek2=kiek2+1; taip = findnext(&ffblk);}} system ("dir/ad/b > temp2.txt"); ff = fopen ("temp2.txt","r"); while (fscanf (ff,"%s",kata)!=EOF) { kiekis (kata); kiek3= kiek+kiek3;} if (fscanf (ff,"%s",kata)==EOF){ kiek3 = kiek3 + kiek2; printf("\n there are files %d",kiek3);} getch(); return (0);}



LinkBack URL
About LinkBacks


