Thank you both for your suggestions. While it is possible I have incorporated your code fragments in the wrong places, both programs did not compile correctly. I have therefore pasted both programs with their relavant compilation errors below:-
1: JohnFill
code
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
struct C {
char Record_Type;
int Customer_Code[5];
int Part_Number[6];
int Issue_Quantity[4];
};
struct C oneInstanceOfStruct;
int main()
{
ifstream infile;
infile.open("test.dat"

;
if(!infile.is_open())
{
cout << "Could not open file" << endl;
exit(1);
}
while(!infile.eof())
{
infile >> oneInstanceOfStruct.Record_Type;
infile >> oneInstanceOfStruct.Customer_Code;
infile >> oneInstanceOfStruct.Part_Number;
infile >> oneInstanceOfStruct.Issue_Quantity;
}
return 0;
}/code
--------------------Configuration: Chapter_6- Win32 Debug--------------------
Compiling...
Chapter_6.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter_6\Chapter_6.cpp(28) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int [5]' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter_6\Chapter_6.cpp(29) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int [6]' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter_6\Chapter_6.cpp(30) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int [4]' (or there is no acceptable conversion)
Error executing cl.exe.
Chapter_6.obj - 3 error(s), 0 warning(s)
2:-CraigD
code
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
#define MAX_RECORDS 200
struct C {
char Record_Type;
int Customer_Code[5];
int Part_Number[6];
int Issue_Quantity[4];
};
int main()
{
FILE *fPtr;
C struct c[MAX_RECORDS];
fPtr = fopen("test.dat", "r"

;
if(fPtr == NULL)
{
cout << "Error opening file\n";
exit(1);
}
for(int i = 0; (i < MAX_RECORDS) && (!fPtr.EOF()); i++)
{
fread(struct_c, 1, sizeof(C), fPtr);
}
fclose(fptr);
return 0;
}/code
--------------------Configuration: Chapter5_ArrayofPointers - Win32 Debug--------------------
Compiling...
PT39.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(15) : error C2065: 'FILE' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(15) : error C2065: 'fPtr' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(15) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(16) : error C2236: unexpected 'struct' 'c'
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(16) : error C2143: syntax error : missing ';' before '['
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(16) : error C2143: syntax error : missing ';' before '['
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(18) : error C2065: 'fopen' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(26) : error C2059: syntax error : '('
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(26) : error C2228: left of '.i' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(26) : error C2143: syntax error : missing ';' before ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\Chapter5_ArrayofPointers\PT39.cpp(27) : error C2143: syntax error : missing ';' before '{'
Error executing cl.exe.
PT39.obj - 10 error(s), 1 warning(s)
I am only a student at the moment(I'm sure you would never have guessed!) so I hope you will both be able to set me straight. Thanks your time.