|
-
Apr 13th, 2001, 06:56 AM
#1
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
-
Apr 13th, 2001, 12:01 PM
#2
Monday Morning Lunatic
How are you reading the file?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 14th, 2001, 07:10 AM
#3
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;
}
-
Apr 14th, 2001, 07:15 AM
#4
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|