Guest_imported
New member
- Jan 1, 1970
- 0
Given a text file of:-
C123450000015000
C223450002134111
C012353302343422
C333450003245436
.. and a structure of:-
struct C {
char Record_Type;
int Customer_Code[5];
int Part_Number[6];
int Issue_Quantity[3];
};
How do I go about putting each line of the text file into the fields of the structure?
I know I require;
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[3];
};
int main()
{
ifstream infile;
infile("test.dat", ios::in || nocreate);
if(!infile.is_open())
{
cout << "Could not open file" << endl;
exit(1);
}
char temp[25];
while(!infile.eof())
infile.getline(temp, 25);/code
But after that I am completely confused! Please help if you can.
C123450000015000
C223450002134111
C012353302343422
C333450003245436
.. and a structure of:-
struct C {
char Record_Type;
int Customer_Code[5];
int Part_Number[6];
int Issue_Quantity[3];
};
How do I go about putting each line of the text file into the fields of the structure?
I know I require;
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[3];
};
int main()
{
ifstream infile;
infile("test.dat", ios::in || nocreate);
if(!infile.is_open())
{
cout << "Could not open file" << endl;
exit(1);
}
char temp[25];
while(!infile.eof())
infile.getline(temp, 25);/code
But after that I am completely confused! Please help if you can.