Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable parameters

Status
Not open for further replies.

joeGrammar

Programmer
Jun 4, 2001
162
CA
Does anyone see anything wrong with this code?

CALL:

printDetailLine(0,szLine,0);

(szLine is a zero-terminated string)


FUNCTIONS:

inline LOGIC Report::printDetailLine( int dummy, ... )
{
va_list argptr;
LOGIC bStatus;

va_start( argptr, dummy );
bStatus = printDetailLine(columns, argptr);
va_end(argptr);
return bStatus;
}

(the next function is called from the dummy function)


inline LOGIC Report::printDetailLine( ColumnList &columns, ... )
{
va_list argptr;

LOGIC bStatus;

va_start(argptr, columns);

bStatus = printDetailLine(columns, argptr);
va_end(argptr);
return bStatus;
}

LOGIC Report::printDetailLine( ColumnList &columns, va_list argptr)
{
t_index iColumns = columns.columnList.GetElementCount();

for ( int iCount = 0; iCount < iColumns; iCount++ )
{
ChangeColParamString ( columns, szBuff, &argptr, iCount );

.....

void Report::ChangeColParamString ( ColumnList &columns, char *szParam, va_list* ValList, t_index iColumns )
{

szBuff = va_arg(*ValList, char*);

sprintf ( szParam, ColToStr.c_str(), szBuff );

}


The program crashed on the sprintf, even when I try to printf the szBuff it doesn't work. Any Ideas? Thanks in advance!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top