Hi,
I'm wanting to be able to read and write two arrays to a file.
Read the arrays when the program opens, and write the arrays when the program closes.
The two arrays are:
char Reg[15][7] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{ 0},{0},{0}};
char Model[15][11] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{ 0},{0},{0}};
My problem is that my program dousn't correctly read and write to the file.
When it writes to the file, it only writes two characters. It should write complete strings.
My code for writing and reading to files are as follows (I am including fstream.h):
=============================================
ifstream inFile;
inFile.open("C:\\parkeasy.dat", ios::in);
if (!inFile.fail())
{
inFile >> Reg[15][7];
inFile >> Model[15][7];
inFile.close();
}
else
{
cout << "Error finding or creating file Carkeasy.dat" << endl;
}
=============================================
ofstream outFile;
outFile.open("C:\\parkeasy.dat", ios:ut);
if(!outFile.fail())
{
outFile << Reg[15][7] << endl;
outFile << Model[15][7] << endl;
outFile.close();
}
else
{
cout << "error opening file" << endl;
}
==============================================
The following is an example of the arrays with strings:
char Reg[15][7] = {{"394EIR"},{"238PNG"},{"138THX"},{"908BAD"},{0},{ 0},{"786GIF"},{0},{"678DOG"},{0},{0},{0},{0},{0},{ 0}};
char Model[15][11] = {{"FALCON"},{"COMMODORE"},{"FAIRLANE"},{"121-METRO"},{0},{0},{"HILUX"},{0},{"SKYLINE"},{0},{0}, {0},{0},{0},{0}};
Any help would be appreciated greatly.