timmay3141
Programmer
I was looking at some code in a Direct3D tutorial and ran across the following function used for debugging:
void WriteToLog(char *lpszText, ...)
{
if(m_fEnableLogging)
{
va_list argList;
FILE *pFile;
//Initialize variable argument list
va_start(argList, lpszText);
//Open the log file for appending
pFile = fopen("log.txt", "a+"
;
//Write the text and a newline
vfprintf(pFile, lpszText, argList);
putc('\n', pFile);
//Close the file
fclose(pFile);
va_end(argList);
}
}
I thought I knew C++ pretty well, but none of the books I've ever used have mentioned using ... as a function parameter. I'd seen it before in printf too, but I'd just ignored it. Anyway, can someone tell me what ... does and how it is being used?
void WriteToLog(char *lpszText, ...)
{
if(m_fEnableLogging)
{
va_list argList;
FILE *pFile;
//Initialize variable argument list
va_start(argList, lpszText);
//Open the log file for appending
pFile = fopen("log.txt", "a+"
//Write the text and a newline
vfprintf(pFile, lpszText, argList);
putc('\n', pFile);
//Close the file
fclose(pFile);
va_end(argList);
}
}
I thought I knew C++ pretty well, but none of the books I've ever used have mentioned using ... as a function parameter. I'd seen it before in printf too, but I'd just ignored it. Anyway, can someone tell me what ... does and how it is being used?