Struct Lookup With Input Files

Hello, I'm looking to create a struct that does the following..

-Open the two input files and test the streams. (I'll post the txt files afterwards to give a better grasp on what I'm working with)
-Stream the data items into a struct member of the array that I'll call inventoryItem struct member of the array.
-Count each inventory item in itemCount and use this value to position the next array element, close the file, and display the count of inventory records.
-Read the purchase records until end of file into purchaseItem struct.
-Use purchaseItem.purchaseItemCode to look up and match an item found in inventoryItem[pos].itemCode array. When a match is found, use pos to select and pass the entire inventoryItem[pos] struct as a parameter to the display routine.
-Use void function displayPurchaseInfo(purchaseRec pInfo, inventoryRec iInfo);
that will output the current line of the purchase info.
-Pass the current purchase record and matching inventory record that was selected as struct parameters.
-Move purchaseTotal to this procedure as a local variable and calculate that value before displaying.
-Multiplay pInfo.purchaseQty by iInfo.itemPrice for output and display iInfo.itemDescription on the output line.


I'm not asking for somebody to come along and create the program for me, but I am asking for a helping hand to point me in the right direction. Youtube didn't seem to have anything other than pretty basic structs that didn't accomplish much, and my book has a little info but I'm still having issues obviously.

Presented below is kind of a skeleton basically declaring some of the things that will be used here, and the .txt files at the very bottom. Any assistance of any sort is really appreciated. Thank you all for giving this a read at least.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

struct purchaseRec
{
	int	purchaseNum;
	string	purchaseItemCode;
	long	purchaseQty;
};
struct inventoryRec
{
	string	itemCode;
	float	itemPrice;
	long	itemOnHand;
	string	itemName;
};
void displayPurchaseInfo(purchaseRec pInfo, inventoryRec iInfo);
int main()
{
	purchaseRec	purchaseItem;
	inventoryRec	inventoryItem[20];
	int		itemCount = 0;
	int		purchaseCount = 0;
	int		pos;

	double purchaseTotal;

	ifstream inventoryFile("Inventory.txt");
	ifstream purchaseFile("Purchases.txt");

	system("pause");
	return 0;
}


My two .txt files purchases.txt and inventory.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
361	DQ114	 31
362	CL120	215
363	FA105	 12
364	FZ225	 21
365	BY604	  1
366	BL114	  2
367	EG802	 16
368	AX205	  3
369	DQ114	 18
370	AX205	  2
371	DD889	325
372	CL455	 78
373	AX205	  5
374	FA105	 43
375	BY604	  2
376	EG802	  3
377	DD889	208
378	FA105	 74
379	FZ225	 32
380	BY604	  4


1
2
3
4
5
6
7
8
9
10
AX205	114.95	 18	Phoenix_Juicer
BL114	149.95	 42	Harper_Sound_Monitor
BY604	469.95	  8	Feld_Convection_Oven
CL120	 27.49	345	Holden_DoorGuard
CL455	 69.95	201	Entrex_Static_Mat
DD889	 14.25	893	Evans_FloorCote
DQ114	 18.49	 81	Lerner_Multi-Timer
EG802	 34.95	 22	Zygran_Humidifier
FA105	  7.95	137	Olden_Video_Splitter
FZ225	 12.49	 73	Yard-eze_CarryAll

Topic archived. No new replies allowed.