D
dave
void CalcPortGrossRet(Funds tf[],int fsize,PortFolio tp,int cmonth)
{
int i=0;
float totgrossdlrval=0;
char converter[10];
while(i<fsize){
tf.enddlrval=(tf.dlrval*(tf.ret[cmonth]/100.0)+tf.dlrval);
totgrossdlrval+=tf.enddlrval;
i++;
}
tp.grossenddlrval=totgrossdlrval;
tp.ret[cmonth]=(tp.grossenddlrval-tp.grossdlrval)/tp.grossdlrval;
sprintf(converter,"%.5f",tp.ret[cmonth]);
MessageBox(NULL,"Monthly return for portfolio is "
+ (CString)converter,"C++ Debugger",NULL);
}
after CalcPortGrossRet is called with
CalcPortGrossRet(thefunds,3,theport,im);
and returns,
theport.grossenddlrval has garbage in it.
While in function tp.grossenddlrval is correct.
tp.grossenddlrval is a float.
theport is defined in the calling function.
whats happening?
thanks
{
int i=0;
float totgrossdlrval=0;
char converter[10];
while(i<fsize){
tf.enddlrval=(tf.dlrval*(tf.ret[cmonth]/100.0)+tf.dlrval);
totgrossdlrval+=tf.enddlrval;
i++;
}
tp.grossenddlrval=totgrossdlrval;
tp.ret[cmonth]=(tp.grossenddlrval-tp.grossdlrval)/tp.grossdlrval;
sprintf(converter,"%.5f",tp.ret[cmonth]);
MessageBox(NULL,"Monthly return for portfolio is "
+ (CString)converter,"C++ Debugger",NULL);
}
after CalcPortGrossRet is called with
CalcPortGrossRet(thefunds,3,theport,im);
and returns,
theport.grossenddlrval has garbage in it.
While in function tp.grossenddlrval is correct.
tp.grossenddlrval is a float.
theport is defined in the calling function.
whats happening?
thanks