Home > Software engineering >  MFC read garbled words at the end of the file
MFC read garbled words at the end of the file

Time:09-27

Small white a cellar! Thank you
Use of vs2015
CFile fileQ;
Cstrings pszfilename=_T (" QQzm. TXT ");
CFileException fileexception;
Int iOpenresult;
IOpenresult=fileQ. CFile: : Open (pszfilename, CFile: : modeCreate | CFile: : modeNoTruncate | CFile: : modeReadWrite, & amp; Fileexception);
if (! IOpenresult)
{
TCHAR szerror [1024].
Fileexception. GetErrorMessage (szerror, 1024);
MessageBoxW (szerror);
FileQ. Close ();
}
The else
{

Int n=0;
N=fileQ. GetLength ();
Char * sread=new char [n + 1);
FileQ. Read (sread, n);
Sread [n]=0;
MessageBoxW (LPCTSTR sread);
FileQ. Close ();
}

CodePudding user response:



The file content 111 111 222 222 333 333 444 444

CodePudding user response:

See you first read length whether there are so many data, then the sread reset after initialization, read it again

CodePudding user response:

What is QQzm. TXT in the content? Determine the text characters?

CodePudding user response:

Recommended WinHex software to check the hard disk or file or original bytes of memory content,

Computer memory or file content or transport it is just a one-dimensional binary byte array and its corresponding binary address;
The human brain to a computer memory or file contents or transfer the content of the one-dimensional binary byte array and its corresponding binary address some parts as an integer, number of signed/unsigned number, floating point Numbers, complex Numbers, letters, digits, Chinese/Korean/French... Character/string, assembly instructions, functions, function parameters, heap, stack, arrays, Pointers, array pointer and pointer array, the array of arrays, pointer to pointer, two-dimensional arrays, character lattice, the coordinates of character strokes, black and white binary images and grayscale images, color images, audio, video, fingerprint information, id information...

CodePudding user response:

With ue to view the following read text files, is there something else behind
Array before using memset 0 x0
Step through see monitoring numerical change

CodePudding user response:

FileQ. Read Read (sread, n) to see if the return value is n, the other in binary view software view under the end of the file what extra bytes,

Ps: pop-up box function parameters for character set, MessageBoxW MessageBox see instead,

CodePudding user response:

Should be the problem of file size
  • Related