Home > Software engineering >  MFC for part of the text file information
MFC for part of the text file information

Time:10-06

Make a afternoon, didn't out for a great god answers

CodePudding user response:

The entire file to be read to come in, and then find themselves need to content

CodePudding user response:

Read the file content, and then their resolution

CodePudding user response:

CFile: : Seek
Virtual LONG Seek (LONG lOff, UINT nFrom);
Throw (CFileException);

The Return Value

If the requested position is legal, Seek returns the new byte offset from the beginning of the file. Otherwise, the return value is undefined and a CFileException object is thrown.

The Parameters

LOff

Number of bytes to move the pointer.

NFrom

Pointer movement mode. Must be one of the following values:

CFile: : begin Move the file pointer lOff bytes forward from the beginning of the file.


CFile: : the current Move the file pointer lOff bytes from the current position in the file.


CFile: : end Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to the seek into the existing file. Positive values will seek past the end of the file.
Few

Repositions the pointer in a previously the opened file. The Seek function permits the random access to a file's contents by moving the pointer a specified amount, absolutely or relatively. No data is later read during the Seek.

When a file is the opened, the file pointer is positioned at offset 0, the beginning of the file.

Example

//example for CFile: : Seek
Extern CFile CFile;
LONG lOffset=1000, lActual;
LActual=cfile. Seek (lOffset cfile: : begin);

CFile Overview | Class Members | Hierarchy Chart

CodePudding user response:

refer to the second floor VisualEleven response:
read the file content, and their analytic


MFC how to read I feel a little conflict with Fstream

CodePudding user response:

 
Cstrings buffer;
Ifstream in;
In the open (" 1. TXT ");
If (in)
{
Char ch;
while (! In the eof ())
{
In the read (& amp; Ch. 1);
Buffer=buffer + ch;
}
}

 size_t stRead. 
Cstrings STR="";
Char szBuffer [1024].
The FILE * fp=NULL;
If (0==fopen_s (& amp; Fp, "LS_monitor. Lbu", "rb") & amp; & Fp)
{
while(! (feof (fp)))
{
Memset (szBuffer, 0, sizeof (szBuffer));
StRead=fread (szBuffer, 1, 1023, fp);
If (stRead & lt;=0 | | stRead & gt; 1023)
{
break;
}
STR +=szBuffer;
}
The fclose (fp);
}

CodePudding user response:

The FILE * fp.
  • Related