Home > Back-end >  For help, the structure error writing appeared
For help, the structure error writing appeared

Time:02-18

I want to design a belongs to my own binaries, appeared both in the aspect of structure to the problem, of course I source may have some other questions, please help me to point out one by one!



//here is the source code






# include & lt; Stdio. H>
# include & lt; Stdint. H>

# define DATA_LENTH_READ 300
# define DATA_LENTH_WRITE 300

The static const uint32_t crc32tab []={
Xee0e612cl x00000000l 0, 0 x77073096l, 0, 0 x990951bal,
Xe963a535l x076dc419l 0, 0 x706af48fl, 0, 0 x9e6495a3l,
Xe0d5e91el x0edb8832l 0, 0 x79dcb8a4l, 0, 0 x97d2d988l,
Xe7b82d07l x09b64c2bl 0, 0 x7eb17cbdl, 0, 0 x90bf1d91l,
Xf3b97148l x1db71064l 0, 0 x6ab020f2l, 0, 0 x84be41del,
Xf4d4b551l x1adad47dl 0, 0 x6ddde4ebl, 0, 0 x83d385c7l,
Xfd62f97al x136c9856l 0, 0 x646ba8c0l, 0, 0 x8a65c9ecl,
Xfa0f3d63l x14015c4fl 0, 0 x63066cd9l, 0, 0 x8d080df5l,
Xd56041e4l x3b6e20c8l 0, 0 x4c69105el, 0, 0 xa2677172l,
Xd20d85fdl x3c03e4d1l 0, 0 x4b04d447l, 0, 0 xa50ab56bl,
Xdbbbc9d6l x35b5a8fal 0, 0 x42b2986cl, 0, 0 xacbcf940l,
Xdcd60dcfl x32d86ce3l 0, 0 x45df5c75l, 0, 0 xabd13d59l,
Xc8d75180l x26d930acl 0, 0 x51de003al, 0, 0 xbfd06116l,
Xcfba9599l x21b4f4b5l 0, 0 x56b3c423l, 0, 0 xb8bda50fl,
Xc60cd9b2l x2802b89el 0, 0 x5f058808l, 0, 0 xb10be924l,
Xc1611dabl x2f6f7c87l 0, 0 x58684c11l, 0, 0 xb6662d3dl,
X98d220bcl x76dc4190l 0, 0 x01db7106l, 0, 0 xefd5102al,
X9fbfe4a5l x71b18589l 0, 0 x06b6b51fl, 0, 0 xe8b8d433l,
X9609a88el x7807c9a2l 0, 0 x0f00f934l, 0, 0 xe10e9818l,
X91646c97l x7f6a0dbbl 0, 0 x086d3d2dl, 0, 0 xe6635c01l,
X856530d8l x6b6b51f4l 0, 0 x1c6c6162l, 0, 0 xf262004el,
X8208f4c1l x6c0695edl 0, 0 x1b01a57bl, 0, 0 xf50fc457l,
X8bbeb8eal x65b0d9c6l 0, 0 x12b7e950l, 0, 0 xfcb9887cl,
X8cd37cf3l x62dd1ddfl 0, 0 x15da2d49l, 0, 0 xfbd44c65l,
Xa3bc0074l x4db26158l 0, 0 x3ab551cel, 0, 0 xd4bb30e2l,
Xa4d1c46dl x4adfa541l 0, 0 x3dd895d7l, 0, 0 xd3d6f4fbl,
Xad678846l x4369e96al 0, 0 x346ed9fcl, 0, 0 xda60b8d0l,
Xaa0a4c5fl x44042d73l 0, 0 x33031de5l, 0, 0 xdd0d7cc9l,
Xbe0b1010l x5005713cl 0, 0 x270241aal, 0, 0 xc90c2086l,
Xb966d409l x5768b525l 0, 0 x206f85b3l, 0, 0 xce61e49fl,
Xb0d09822l x5edef90el 0, 0 x29d9c998l, 0, 0 xc7d7a8b4l,
Xb7bd5c3bl x59b33d17l 0, 0 x2eb40d81l, 0, 0 xc0ba6cadl,
X03b6e20cl xedb88320l 0, 0 x9abfb3b6l, 0, 0 x74b1d29al,
X04db2615l xead54739l 0, 0 x9dd277afl, 0, 0 x73dc1683l,
X0d6d6a3el xe3630b12l 0, 0 x94643b84l, 0, 0 x7a6a5aa8l,
X0a00ae27l xe40ecf0bl 0, 0 x9309ff9dl, 0, 0 x7d079eb1l,
X1e01f268l xf00f9344l 0, 0 x8708a3d2l, 0, 0 x6906c2fel,
X196c3671l xf762575dl 0, 0 x806567cbl, 0, 0 x6e6b06e7l,
X10da7a5al xfed41b76l 0, 0 x89d32be0l, 0, 0 x67dd4accl,
X17b7be43l xf9b9df6fl 0, 0 x8ebeeff9l, 0, 0 x60b08ed5l,
X38d8c2c4l xd6d6a3e8l 0, 0 xa1d1937el, 0, 0 x4fdff252l,
X3fb506ddl xd1bb67f1l 0, 0 xa6bc5767l, 0, 0 x48b2364bl,
X36034af6l xd80d2bdal 0, 0 xaf0a1b4cl, 0, 0 x41047a60l,
X316e8eefl xdf60efc3l 0, 0 xa867df55l, 0, 0 x4669be79l,
X256fd2a0l xcb61b38cl 0, 0 xbc66831al, 0, 0 x5268e236l,
X220216b9l xcc0c7795l 0, 0 xbb0b4703l, 0, 0 x5505262fl,
X2bb45a92l xc5ba3bbel 0, 0 xb2bd0b28l, 0, 0 x5cb36a04l,
X2cd99e8bl xc2d7ffa7l 0, 0 xb5d0cf31l, 0, 0 x5bdeae1dl,
X756aa39cl x9b64c2b0l 0, 0 xec63f226l, 0, 0 x026d930al,
X72076785l x9c0906a9l 0, 0 xeb0e363fl, 0, 0 x05005713l,
X7bb12bael x95bf4a82l 0, 0 xe2b87a14l, 0, 0 x0cb61b38l,
X7cdcefb7l x92d28e9bl 0, 0 xe5d5be0dl, 0, 0 x0bdbdf21l,
X68ddb3f8l x86d3d2d4l 0, 0 xf1d4e242l, 0, 0 x1fda836el,
X6fb077e1l x81be16cdl 0, 0 xf6b9265bl, 0, 0 x18b74777l,
X66063bcal x88085ae6l 0, 0 xff0f6a70l, 0, 0 x11010b5cl,
X616bffd3l x8f659effl 0, 0 xf862ae69l, 0, 0 x166ccf45l,
X4e048354l xa00ae278l 0, 0 xd70dd2eel, 0, 0 x3903b3c2l,
X4969474dl xa7672661l 0, 0 xd06016f7l, 0, 0 x3e6e77dbl,
X40df0b66l xaed16a4al 0, 0 xd9d65adcl, 0, 0 x37d83bf0l,
X47b2cf7fl xa9bcae53l 0, 0 xdebb9ec5l, 0, 0 x30b5ffe9l,
X53b39330l xbdbdf21cl 0, 0 xcabac28al, 0, 0 x24b4a3a6l,
X54de5729l xbad03605l 0, 0 xcdd70693l, 0, 0 x23d967bfl,
X5d681b02l xb3667a2el 0, 0 xc4614ab8l, 0, 0 x2a6f2b94l,
X5a05df1bl xb40bbe37l 0, 0 xc30c8ea1l, 0, 0 x2d02ef8dl
};

Uint32_t crc32 (const unsigned char * buf, uint32_t size)
{
Uint32_t I, CRC;
CRC=0 XFFFFFFFF;
For (I=0; I & lt; The size; I++)
CRC=crc32tab [(CRC ^ buf [I]) & amp; 0 XFF) ^ (CRC & gt; & gt; 8);
The return of CRC ^ 0 XFFFFFFFF;
}

Void ReadSOTFile (char * FileName []) {

Char FileNum1ch=NULL;

Struct FileData_READ
{
Char MagicNumbers [4].
Uint32_t crc32;
Unsigned long long int FileLenth;
Char FileData [DATA_LENTH_READ];
} FDR1;

The FILE * FileReadIn=fopen (FileName, "rb");

if (! FileReadIn)
{
Puts (" a file or directory does not exist ");
The return - 1;
}

FileNum1ch=fgetc (FileReadIn);
If (FileNum1ch==EOF)
{
Puts (" file is empty ");
The return - 2;
}

Fread (& amp; FDR1, sizeof (struct FileData_READ), 1, FileReadIn);

If (FDR1 MagicNumbers!="SOT \ n")
{
Puts (" it's not. Sots ");
The return - 3;
}

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related