Home > Back-end >  Why c data saved file is the code
Why c data saved file is the code

Time:09-25

I an input file function code is as follows:

Void the write ()
{
Personel p;
P.i n ();
Ofstream myfile (" f1. Dat ", the ios: : binary | ios: : ate);
Myfile. Write ((char *) & amp; P, sizeof p);
Myfile. Close ();
}
But after I input some data, to open the file f1 is garbled, can someone answer next, grateful,

CodePudding user response:

Speculation is the wide character problem

CodePudding user response:

A class is personel? What is the sizeof p?
If it is a structure (no way), sizeof (p) writing should be no problem,
Ios: : ate is additional?
WinHex check written to the file to see what the reason,

CodePudding user response:

WinHex view of time attention byte alignment problem
  • Related