E
efrenba
Hi,
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
well, the problem is:
I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.
The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.
Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get
I hope that you can help me...
here's the code:
--------------
ifstream _fileStream;
TStructure_V250_Data _buffer250;
//open the file...
char* _fName = new char[_fileName.Length() +1];
strcpy(_fName, _fileName.c_str());
_fileStream.open(_fName, ios::binary);
delete [] _fName;
//read data...
_fileStream.read((char*)&_buffer250, sizeof(_buffer250));
---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250_Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
} TStructure_V250_Data;
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
well, the problem is:
I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.
The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.
Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get
I hope that you can help me...
here's the code:
--------------
ifstream _fileStream;
TStructure_V250_Data _buffer250;
//open the file...
char* _fName = new char[_fileName.Length() +1];
strcpy(_fName, _fileName.c_str());
_fileStream.open(_fName, ios::binary);
delete [] _fName;
//read data...
_fileStream.read((char*)&_buffer250, sizeof(_buffer250));
---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250_Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
} TStructure_V250_Data;