Question: 3. Modify the code here: lab7.txt so that the print function prints out the contents of nested folders indented by two spaces. For example, for

3. Modify the code here: lab7.txt so that the print function prints out the contents of nested folders indented by two spaces. For example, for the folder f3 in the main you were given, it would print out:

Folder 3

test1.txt

test2.txt

test3.txt

test4.txt

Folder 1

hw1.txt

hw2.txt

hw3.txt

Empty

Test your function using the main() provided in lab7.txt .

lab7.txt:

#include

#include

using namespace std;

struct Folder{

string name;

string files[100];

int nfiles;

Folder* folders;

int nfolders;

};

void print(Folder f);

int main()

{

Folder fs0[0]={};

Folder f1 = {"Folder1", {"hw1.txt", "hw2.txt", "hw3.txt"}, 3, fs0, 0};

Folder f2 = {"Empty", {}, 0, fs0, 0};

Folder fs[2] = {f1, f2};

Folder f3 = {"Folder3", {"test1.txt", "test2.txt", "test3.txt", "test4.txt"},4, fs,2};

print(f3);

return 0;

}

void print(Folder f){

cout<

for(int i = 0; i

cout<

}

for(int j = 0; j< f.nfolders; j++){

cout<

print(f.folders[j]);

}

}

!!! In C++ !!!!!

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!