Problem: The user should be able to specify a field and a value for that field and the program returns all works that match. For example, the user may specify Artist and Smithely, and the program will output all of the information concerning every work in the gallery by that artist.
My problem is being unable to search through the file and output the correct result. this is what i have so far. thank you for your help
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
const int NUM_PIECES = 120; //represents the max artworks available
enum Medium{OIL, WATERCOLOR, PASTEL, ACRYLIC, PRINT, COLORPHOTO, BLACKANDWHITEPHOTO};
float mediumType[7]; //array of 7 floats, to be indexed by Medium type.
Medium mtype; //variable of the index type
enum Room{MAIN, GREEN, BLUE, NORTH, SOUTH, ENTRY, BALCONY};
float roomType[7]; //array of 7 floats, to be indexed by Room type
Room rtype; //variable of the index type
struct Artwork
{
string Artist;
string Title;
float Price;
int height;
int width;
};
//function prototypes
void Openfiles(istream& inData);
void InputNames(string[], ifstream& inData);
int main()
{
ifstream inData;
int count[NUM_PIECES];
string name[NUM_PIECES]; // array of artworks names
inData.open("C:/art.txt");
if(!inData)
{
cout<<"Error: File cannot be opened. Please try again.";
return 1;
}
for ( int artworks = 0; artworks < NUM_PIECES; artworks++) //initializing array
{
count[artworks] = 0;
}
InputNames(string);
cin.get(); cin.get();
return 0;
}
void Openfiles( /* inout*/ ifstream& text)
{
string inFileName;
cout << "Enter the name of the file to be processed"<< endl;
cin >>inFileName;
text.open(inFileName.c_str());
}
void InputNames(int string[], ifstream& inData)
{
int strings;
//zero out the array of counters
for (int index = 0; index <= 120; index++)
string[index] = 0;
inData >> strings;
while(inData)
{
string[strings];
inData >> strings;
}
}