-
Hello,
I have created a random file in VB. I have tried to access this file using C++ although the file gets read , I am having trouble getting the data in their respective fields. ( data in the first field overflows into the second field and the second field into the next one.)
I have used the following specifications..
IN VB
struct logstruct
cStatus *150
cDate *15
cTime * 15
End struct
dim logdata as logstruct
In C++ I used the following specifications to read the file
struct
{
char cStatus[150];
char cDate[15];
char cTime[15];
};
I am using .dat files
Thank you
Barnabas
-
How are you reading the file?
-
reading the file
I have used the following code to read the first record in the file.
please note the file has already been created in a VB application using the Open...For Random statement.
struct
{
char cStatus[150];
char cDate[15];
char cTime[15];
};
int main()
{
struct logstruct logdata;
fstream datafile;
datafile.open("C:\\DLog.dat",ios::in);
datafile>>logdata;
datafile.close;
cout << logdata.cStatus;
cout << logdata.cDate;
cout << logdata.cTime;
return 0;
}
-
In C++ you don't need struct logstruct logdata -- just use logstruct logdata :)
All I can suggest is try using:
Code:
datafile > logdata;
This will load it BINARY rather than text mode.