Respuesta :
Answer:
Implementation of the given problem in C++:
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<string> category, name, description, availability;
string str;
cout << "Enter the name of text file to open: ";
cin >> str;
ifstream file(str);
while (getline(file, str)) {
size_t pos1 = str.find('\t'); // to find the first tab delimiter
size_t pos2 = str.find('\t', pos1 + 1); // to find the second tab delimiter
size_t pos3 = str.find('\t', pos2 + 1); // to find the third tab delimiter
category.push_back(str.substr(0, pos1));
name.push_back(str.substr(pos1 + 1, pos2 - pos1 - 1));
description.push_back(str.substr(pos2 + 1, pos3 - pos2 - 1));
availability.push_back(str.substr(pos3 + 1, str.length() - pos3));
}
for (int i = 0; i < name.size(); i++)
if (availability[i] == "Available")
cout << name[i] << " (" << category[i] << ") -- " << description[i] << endl;
}
Output:-

The program is an illustration of file manipulations in C++.
File manipulation involves writing to and reading from a file
The program in C++ where comments are used to explain each line is as follows:
#include <bits/stdc++.h>
using namespace std;
int main() {
//This declares all vector variables
vector<string> catg, name, desc, status;
//This declares the file name as a string variable
string fname;
//This prompts the user for the filename
cout <<"Filename: ";
//This gets input for the filename
cin >> fname;
//This opens the file
ifstream file(fname);
//The following is repeated till the end of the file
while (getline(file, fname)) {
//This finds the first tab delimiter
size_t pos1 = fname.find('\t');
//This finds the second tab delimiter
size_t pos2 = fname.find('\t', pos1 + 1);
//This finds the third tab delimiter
size_t pos3 = fname.find('\t', pos2 + 1);
//The next four lines populate the vector variables
catg.push_back(fname.substr(0, pos1));
name.push_back(fname.substr(pos1 + 1, pos2 - pos1 - 1));
desc.push_back(fname.substr(pos2 + 1, pos3 - pos2 - 1));
status.push_back(fname.substr(pos3 + 1, fname.length() - pos3));
}
//This iterates through the file, line by line
for (int i = 0; i < name.size(); i++){
//This prints each line
if (status[i] == "Available"){
cout << name[i] << " (" << catg[i] << ") -- " << desc[i] << endl;
}
}
return 0;
}
Read more about similar programs at:
https://brainly.com/question/15456319