Click here to Skip to main content
16,005,697 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dynamic Array template Pin
Tomasz Sowinski8-Oct-01 1:43
Tomasz Sowinski8-Oct-01 1:43 
GeneralRe: Dynamic Array template Pin
Giles8-Oct-01 7:49
Giles8-Oct-01 7:49 
GeneralRe: Dynamic Array template Pin
Tomasz Sowinski8-Oct-01 9:45
Tomasz Sowinski8-Oct-01 9:45 
GeneralRe: Dynamic Array template Pin
Giles10-Oct-01 8:11
Giles10-Oct-01 8:11 
QuestionSTD C++ less efficient than MFC C++? Pin
7-Oct-01 6:41
suss7-Oct-01 6:41 
AnswerRe: STD C++ less efficient than MFC C++? Pin
Rostrox7-Oct-01 6:54
Rostrox7-Oct-01 6:54 
GeneralRe: STD C++ less efficient than MFC C++? Pin
Fazlul Kabir7-Oct-01 7:14
Fazlul Kabir7-Oct-01 7:14 
AnswerRe: STD C++ less efficient than MFC C++? Pin
Sprudling7-Oct-01 10:39
Sprudling7-Oct-01 10:39 
Maybe you should check out how CStdioFile class actually does the copying of the file. This is how it does it, and it seems to me like it's using what your friend calls "standard C++". (With the exception of CString)

BOOL CStdioFile::ReadString(CString& rString)
{
	ASSERT_VALID(this);

	rString = &afxChNil;    // empty string without deallocating
	const int nMaxSize = 128;
	LPTSTR lpsz = rString.GetBuffer(nMaxSize);
	LPTSTR lpszResult;
	int nLen = 0;
	for (;; )
	{
		lpszResult = _fgetts(lpsz, nMaxSize+1, m_pStream);
		rString.ReleaseBuffer();

		// handle error/eof case
		if (lpszResult == NULL && !feof(m_pStream))
		{
			clearerr(m_pStream);
			AfxThrowFileException(CFileException::generic, _doserrno,
				m_strFileName);
		}

		// if string is read completely or EOF
		if (lpszResult == NULL ||
			(nLen = lstrlen(lpsz)) < nMaxSize ||
			lpsz[nLen-1] == '\n')
			break;

		nLen = rString.GetLength();
		lpsz = rString.GetBuffer(nMaxSize + nLen) + nLen;
	}

	// remove '\n' from end of string if present
	lpsz = rString.GetBuffer(0);
	nLen = rString.GetLength();
	if (nLen != 0 && lpsz[nLen-1] == '\n')
		rString.GetBufferSetLength(nLen-1);

	return lpszResult != NULL;
}


void CStdioFile::WriteString(LPCTSTR lpsz)
{
	ASSERT(lpsz != NULL);
	ASSERT(m_pStream != NULL);

	if (_fputts(lpsz, m_pStream) == _TEOF)
		AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
}


Sprudling
AnswerRe: STD C++ less efficient than MFC C++? Pin
Tim Smith7-Oct-01 11:26
Tim Smith7-Oct-01 11:26 
GeneralRe: STD C++ less efficient than MFC C++? Pin
Rostrox7-Oct-01 14:34
Rostrox7-Oct-01 14:34 
QuestionHow to convert char * to LPWSTR ?? Pin
adara7-Oct-01 5:00
adara7-Oct-01 5:00 
AnswerRe: How to convert char * to LPWSTR ?? Pin
7-Oct-01 7:08
suss7-Oct-01 7:08 
AnswerRe: How to convert char * to LPWSTR ?? Pin
Tim Smith7-Oct-01 8:43
Tim Smith7-Oct-01 8:43 
AnswerRe: How to convert char * to LPWSTR ?? Pin
Christian Graus7-Oct-01 13:23
protectorChristian Graus7-Oct-01 13:23 
AnswerRe: Just use some useful ATL macros Pin
7-Oct-01 19:44
suss7-Oct-01 19:44 
GeneralPrint Preview Events Pin
7-Oct-01 2:40
suss7-Oct-01 2:40 
GeneralPrinting Error Pin
7-Oct-01 2:36
suss7-Oct-01 2:36 
GeneralShellExecute Pin
Maer7276-Oct-01 17:59
Maer7276-Oct-01 17:59 
GeneralRe: ShellExecute Pin
Tim Smith7-Oct-01 2:03
Tim Smith7-Oct-01 2:03 
GeneralRe: ShellExecute Pin
Maer7279-Oct-01 1:39
Maer7279-Oct-01 1:39 
GeneralRe: ShellExecute Pin
8-Oct-01 4:20
suss8-Oct-01 4:20 
GeneralRe: ShellExecute Pin
Maer7279-Oct-01 2:20
Maer7279-Oct-01 2:20 
Generalhttp download Pin
Peter Molnar6-Oct-01 14:08
Peter Molnar6-Oct-01 14:08 
GeneralFormatMessageW for 95/98/ME Pin
Tim Smith6-Oct-01 12:47
Tim Smith6-Oct-01 12:47 
GeneralSticky Notes Pin
shadowplayer6-Oct-01 10:19
shadowplayer6-Oct-01 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.