Char * ReadLob (CString filename)
{
Char msgbody [1024];
Return msgbody
}
//////////////////////////////////////// //////////////////////////////////////// /// // <Difference
Int ReadLob (CString filename, char * node702_msgbody, int iSz)
{
Std: ifstream file; file. open (filename );
If (! File)
{Printf ("Unable to open file \ n"); return-1 ;}
Char pBuf [1024*4]; int iRead = 0, iCur = 0;
While (! File. eof ())
{
File. read (pBuf, sizeof (pBuf ));
IRead = file. gcount ();
Int iCpy = iRead + iCur> = iSz? ISz-iCur-1: iRead;
Strncpy (node702_msgbody + iCur, pBuf, iCpy); iCur + = iCpy;
If (iCur = sizeof (node702_msgbody)-1)
Break;
}
Node702_msgbody [iCur] = 0;
Return 0;
}
///////////////////////////
First, the pointer must be new before it can be used as the return value. If the array header in the function is not returned as a pointer, a problem may occur,
The reason why I did not encounter a problem is that there is no other code in it to destroy the previous stack space.
The CString type can be returned, and the CString can be protected.
The second method is recommended.
///////////////////////////
It is better to add iCur to read fields in segments.