Home > Back-end >  A. Bin file, the first 3 bytes are frame, from 4 to 15 bytes is useful; C read, don't know wher
A. Bin file, the first 3 bytes are frame, from 4 to 15 bytes is useful; C read, don't know wher

Time:09-22

Data. Bin:


 # include 
# include
using namespace std;
//unsigned long nFileBytes;//used to store the BIN file to the total number of bytes
//unsigned char aBinByte [65536].//used to store data that was obtained from the BIN file
Struct MINS
{
Short gyro_z;;
Short gyro_x;
Short gyro_y;
Short acc_z;
Short acc_x;
Short acc_y;
};
Void main ()
{
Fstream infile (" data ", the ios: : | in ios: : binary);
MINS data [5].
cout<& lt; Sizeof (data [0]) & lt; & lt; endl;
for(int i=0; i<5; I++)
{
Infile. Seekg (I * 19, the ios: : beg);
Infile. Seekg (3, the ios: : cur);
Infile. Read ((char *) & amp; Data [I], sizeof (data [0]));
cout<& lt; Data [I] gyro_z & lt; <" "& lt; & lt; Data [I] gyro_x & lt; <" "& lt; & lt; Data [I] gyro_y & lt; & lt; endl;
cout<& lt; Data [I] acc_z & lt; <" "& lt; & lt; Data [I] acc_x & lt; <" "& lt; & lt; Data [I] acc_y & lt; & lt; endl;

}
system("pause");
}

After the compilation is always like this:

Feel the potential errors (char *) & amp; Data [I]; Mandatory type into here, but I don't know how to change, a great god for help

CodePudding user response:

Before you judge from the file to read and write it open if success:
If (infile. Is_open ()
{
.
infile.close();
}
The else
{
//file open failed...
}

CodePudding user response:

Well, I have discovered, the literature to open name. Dat
But solve data or don't feel quite right,
2 bytes (hexadecimal) into a signed short plastic, how convert?
Such as 00, 3, 4 bytes of 11 said how much ah, feel out the numerical value solution is not quite right! To solve!

CodePudding user response:

00 11 should be 17

CodePudding user response:

00 00 is 17, is 11? Low is eight in the top, high 8 in the back? Is this meaning?
The 32 bit integer, 06 4 b, 6 c 84 calculation should become 84 6 c 4 b 6? Is this meaning?

CodePudding user response:

The size of the problem...
  • Related