E D R , A S I H C RSS

Cpp에서의가변인자

가변 란?

C io 라브러리 printf 는 그것다. 또는 MFC - CString CString::Format CString::AppendFormat 는 그것 다. 때 ...라고 나를 가변라고 다. 렇게 러개를 다.

가변 만들

~cpp 
void Foo(LPCTSTR pFmt, ...)
{
	int		len;
	va_list		args;
	TCHAR		*pbuf;
	CString		str;

	va_start(args, pFmt);
	len  = _vsctprintf(pFmt, args) + 1;
	pbuf = new TCHAR[len];
	_vstprintf(pbuf, pFmt, args);

	AfxMessageBox(str);

	SAFEDELETE(pbuf);
}
렇게 면 된다. 뭐가 뭔는.. MSDN . 몰라 다.

는 곳

AfxMessageBox류를 다. 가변를 몰랐
~cpp 
CString str;
str.Format(_T("a : %d, b : %d, c: %d"), a, b, c);
AfxMessageBox(str);
만,
가변고 난 렇게 다.
~cpp 
VAMessageBox(_T("a : %d, b : %d, c: %d"), a, b, c);	// variant argument(?) 같다. 

런 메 몰랐는데~ -
다.--; 그냥 만든; --


Java 1.5 가변 관련 문법 가되다. 곧 printf 가 가될 것다.; --1002

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:02
Processing time 0.0090 sec