Hey guys,
I've been working on this assignment and i'm to the last part of it. The program was to make a function to check the file by a user-defined file name and open it. And once open, i am supposed to read from the integer from the first file and use that integer in the second file by showing how many rows to do for each string. Then in the second file I am supposed to multiply the int * the double and correspond the total by each name.

I figured out how to do the ReadFirstFile function, but the ReadSecondFile function (which i know is totally wrong in my code) i am totally lost on how to make an Array using a FOR loop within a FOOR loop to do the second part.. can anyone help me out?? Any help would be appreciated!!

The description is:
Next, using the data in the integer array, read the appropriate number of data items from the second input
file. Remember, there are three (3) pieces of data for each data item (line). While reading the "gadget"
data, keep a total dollar amount of inventory for that person. Again, you must use the integer stored in the
integer array to determine how many "gadget" items to read from the second input file.
As you finish reading "gadget" items for one person, print a line of output that consists of the person's name
and the total dollar amount for all of their inventory (gadget) items. For example, since Mickey Mouse has
the integer 4 included in its data line, you must read 4 "gadget" items from the second file. This means
Mickey Mouse has 45 hammers, 20 screwdrivers, 28 box cutters, and 14 wrenches in his inventory. Using
the unit prices of $2.79 (hammer), $2.59 (screwdriver), $1.99 (box cutter), and $2.34 (wrench), Mickey
Mouse will have a total dollar amount of inventory of $265.83. NOTE: We don't use the gadget name,
although you must read it from the file to get to the gadget count and unit price.

My first input file is:
4 Mickey Mouse
2 Donald Duck
7 Wile E. Coyote
5 Roadrunner
1 Foghorn Leghorn

My second input file is:
hammer 45 2.79
screwdriver 20 2.59
boxCutter 28 1.99
wrench 14 2.34
milk 27 2.09
butter 12 3.89
tablet 165 0.59
pen 89 1.19
pencil 145 0.79
tape 67 1.25
staples 94 1.79
erasers 82 0.67
markers 23 2.99
printer 5 78.99
mouse 35 9.99
monitor 5 298.95
flashDrive 30 44.99
CD-ROM 84 0.99
blankets 18 34.98

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
void OpenCheck(ifstream&, string);
int ReadFirstFile(ifstream&,int[],string[]);
int ReadSecondFile(ifstream&,string[],int[],double[]);

int main()
{
    ifstream inFile1, inFile2;
    int num, count, count2;
    int intArray[50];
    string strArray[50];
    double dArray[50];
    string name, file1, file2;
    
    cout << "Enter a name for first input file:";
    cin >> file1;
    cout << "\nEnter a name for the second input file:";
    cin >> file2;
        
    OpenCheck(inFile1, file1);
    OpenCheck(inFile2, file2);

    count = ReadFirstFile(inFile1,intArray,strArray);
    count2 = ReadSecondFile(inFile2,strArray,intArray,dArray);

    system("Pause");
    return 0;

}

//functioin definition for OpenCheck
void OpenCheck(ifstream& inFile1,string file)
{
     inFile1.open(file.c_str());
     
     if(inFile1.fail())
     {
         cout << "Error Opening "
         << file
         << ". Program Terminated. \n";
         system("Pause");
         exit(1);
     }
}

//function definition for ReadFirstFile
int ReadFirstFile(ifstream& inFile1,int intArray[],string strArray[])
{
    int count, num;
    string name;

    // priming read
    inFile1 >> num;
    getline(inFile1,name);
    for (count = 0; count < 50; count++)
    {
        // store data in the integer and string arrays
        intArray[count] = num; 
        strArray[count] = name;
        // repeat priming read
        inFile1 >> num;
        //cout << strArray[count] << " ";
        getline(inFile1,name);
    }
    return count;
}

int ReadSecondFile(ifstream& inFile2,string strArray[], int intArray[], double dArray[])
{
    int count2, num2;
    string gadgets;
    double price;
    
    // priming read
    inFile2 >> num2;
    getline(inFile2,gadgets);
    for (count2 = 0; count2 < 50; count2++)
    {
        // store data in the integer and string arrays
        intArray[count2] = num2; 
        strArray[count2] = gadgets;
        dArray[count2] = price;
        // repeat priming read
        inFile2 >> num2;
        cout << count2;
        cout << strArray[count2] << " ";

        getline(inFile2,gadgets);
    }
    return count2;
}