Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.In this program its job is to reads the data from a text file the data from the text file is about files and folders

1.In this program its job is to reads the data from a text file the data from the text file is about files and folders stored in a storage device, here is the code I have done:

#include #include #include using namespace std; class Data_Struct { private: vectorlines; // vector of string which stores the file line by line public: void loadFromFile(string fileName)// this function reads the txt file and stores the content line by line in the lines vector { string str; // for taking input ifstream Data_Struct; // variables for reading the file Data_Struct.open(fileName); // opeining the file if(!Data_Struct)// if file could not open then error msg is printed { cout<<"ERROR in file loading . "; return; } while (getline(Data_Struct,str)) // read every line and stores in the vector { lines.push_back(str); } Data_Struct.close(); // closing the file } void printlines()// method for printing the contents line by line from vector and the id number { for (int i=0; i < lines.size(); i++) { cout << lines[i] << " "; cout<< getNumber(lines[i])<<" "; } }

char getNumber(string line) // getting the ID number from the first line of file { return line[1]; } };

#include #include #include "Data_Struct.h" using namespace std;

int main() {

string fileName = "file.txt";// file name is stored in the filename variable Data_Struct dataStruct;// creating the object of the file class dataStruct.loadFromFile(fileName);// reading the contents dataStruct.printlines();// printing the contents of the file

return 0; }

Here is the output:

[0][Root][0][T][0] the ID number is:0 [1][file.txt][45643][F][0] the ID number is:1 [2][folder1][0][T][0] the ID number is:2 [3][file2.txt][7346][F][2] the ID number is:3

now I wish to put this data in a binary three using the id number of each number. The problem is that the root has to begin with 0. And after that the program should list search delete and add files or folders through the binary three. finally the application should be abble to export the tree data structure currently in memory to a text file respecting the format as shown in the output so it can reopen the application. The program must be written in c++ object oriented and the library classes used must be shown and the program must be with comments so it can be understandable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago