C++ string values

teddym

Member
Hi,

Would anyone know how to add commas to string number values? Following is the code where I think it should be happening.

Thanks in advance.


/* Product Line */
FormatMathNumeric (Amount1, &lpDS->mnAmountField1);
FormatMathNumeric (Amount2, &lpDS->mnAmountField2);

MathRound(&mnAmountRounded, &lpDS->mnAmountField3, &nDecimalsToRound);
FormatMathNumeric (Amount3, &mnAmountRounded);

MathRound(&mnAmountRounded, &lpDS->mnAmountField4, &nDecimalsToRound);
FormatMathNumeric (Amount4, &mnAmountRounded);

/* Format decimal section of amount, if missing two digits.
Add a zero at the end */

FormatMathNumeric(Amount1, "#,###");
AlignDecimalDigits(Amount1, lpDS->cDecimalSeparator);
AlignDecimalDigits(Amount2, lpDS->cDecimalSeparator);
AlignDecimalDigits(Amount3, lpDS->cDecimalSeparator);
AlignDecimalDigits(Amount4, lpDS->cDecimalSeparator);

if (lpDS->cEstimatedSales == 'Y')
{
strcpy(Estimated, "*");
}
else
{
strcpy(Estimated, " ");
}

FormatMathNumeric (Percentage, &lpDS->mnPercentageDueOnSales);
sprintf(TempText[4], "Total gross sales %s for the period", lpDS->szProductCode);
sprintf(TempText[4], "%-50s%13s%2s\r\n", TempText[4] , Amount1, Estimated);

/* Check for existence of Breakpoint by chequing Amount3 */
if ((strcmp(Amount3, "0,00") != 0) && (strcmp(Amount3, "0.00")!= 0) && (strcmp(Amount3, ".00") != 0) && (strcmp(Amount3, ",00") != 0))
{
/* Set flag for Breakpoint printing */
BreakpointFlag = 'Y';

sprintf(TempText[5], " Less: Breakpoint");
sprintf(TempText[5], "%-50s%13s\r\n", TempText[5], Amount3);
sprintf(TempText[6], "%-50s%s\r\n", " ", "-------------");
sprintf(TempText[7], " Sales %s to Invoice", lpDS->szProductCode);
sprintf(TempText[7], "%-50s%13s\r\n", TempText[7] , Amount4);
sprintf(TempText[8], "%s\r\n", " "); /* Blank Line */
}

sprintf(TempText[9], " Sales %s %s at %s%%", lpDS->szProductCode , Amount4,Percentage);
sprintf(TempText[9], "%-62s%13s\r\n", TempText[9] , Amount2);
sprintf(TempText[10], "%s\r\n", " "); /* Blank Line */
break;
 

maguirem

Member
Hi Teddym,

I had a look at your question and the code you attached, and I could not correlate your question with the code. Is there a compiler error when building the function? Or are you getting a run-time error.

Please just send the line of code that appears to give you the error and I'll take a closer look, but I do not have time to troll through 50 lines of code for the line that might be broken.

Regards

Mike
 
Top