#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void main (void)
{	
	int i; 
	string author[5], title[5],cost[5],number[5];
	float fcost[5];
	int inumber[5];
	fstream file1; //fstream is used to declare a file 

	file1.open("test.dat",ios::in);	//the file test.dat is opened for input (to read the data stored in it)

	for (i=0;i<5;i++)	//this loop reads the data from the file and stores it in the strings
	{
		getline(file1, author[i],'/');
		getline(file1, title[i],'/');
		getline(file1, cost[i],'/');
		getline(file1, number[i],'/');
	}

	for (i=0;i<5;i++)	// this loop converts string data to numeric data
	{
		fcost[i] = stof(cost[i]);
		inumber[i] = stoi(number[i]);
	}

	cout<<"the array has now been filled with data from the file.\n";
	cout<<"the array data currently contains the following information:\n";
	cout << "\n\n Author		   Book		Price	Stock\n";
	for (i=0;i<5;i++)
	{
		cout<<author[i]<<"\t ";
		cout<<title[i]<<"\t ";
		cout<<fcost[i]<<"\t ";
		cout<<inumber[i]<<"\n";
	}
	file1.close();	//the file is closed
}