Question: Someone write comments to each line of code that what is going on in code. #include #include #include #include #include #include #include int breadth_first(char dirname[])

Someone write comments to each line of code that what is goingon in code. #include #include #include #include #include #include #include int breadth_first(charSomeone write comments to each line of code that what is going on in code.

#include #include #include #include #include #include #include int breadth_first(char dirname[]) { DIR *mydir; struct dirent *myfile; struct stat mystat; int counter = 0; char buf[1024]; mydir = opendir(dirname); while((myfile = readdir(mydir)) != NULL) { char *s1="."; char *s2=".."; if(strcmp(myfile->d_name,s1)==0 || strcmp(myfile->d_name,s2)==0) { continue; } printf("\t%s ", myfile->d_name); stat(myfile->d_name, &mystat); if((int)mystat.st_nlink) { counter++; } } printf("Hardlinks in CWD :: %d ", counter); printf("############## ##### "); rewinddir(mydir); while((myfile = readdir(mydir)) != NULL) { char *s1=".": char *s2="."; if(strcmp(myfile->d_name,s1)==0 || strcmp(myfile->d_name,s2)==0) { continue; } stat(myfile->d_name, &mystat); if(S_ISDIR/mystat.st_mode)) { printf("%s ", myfile->d_name); counter += breadth_first(myfile->d_name); } } closedir(mydir); return counter; } int main() { int counter = breadth_first(":"); printf("Hardlinks Total :: %d ", counter); return 0; } #include #include #include #include #include #include #include int breadth_first(char dirname[]) { DIR *mydir; struct dirent *myfile; struct stat mystat; int counter = 0; char buf[1024]; mydir = opendir(dirname); while((myfile = readdir(mydir)) != NULL) { char *s1="."; char *s2=".."; if(strcmp(myfile->d_name,s1)==0 || strcmp(myfile->d_name,s2)==0) { continue; } printf("\t%s ", myfile->d_name); stat(myfile->d_name, &mystat); if((int)mystat.st_nlink) { counter++; } } printf("Hardlinks in CWD :: %d ", counter); printf("############## ##### "); rewinddir(mydir); while((myfile = readdir(mydir)) != NULL) { char *s1=".": char *s2="."; if(strcmp(myfile->d_name,s1)==0 || strcmp(myfile->d_name,s2)==0) { continue; } stat(myfile->d_name, &mystat); if(S_ISDIR/mystat.st_mode)) { printf("%s ", myfile->d_name); counter += breadth_first(myfile->d_name); } } closedir(mydir); return counter; } int main() { int counter = breadth_first(":"); printf("Hardlinks Total :: %d ", counter); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!