Locale, huh? Never would have searched for that. Thanks, Salem.
For those who are "locale-challenged", this is a C way of doing that right justified and with comma's, number printout.
In this code snippet, sprintf is first putting the result of the computations back into a string called "folder[1].strpoints" (which is in the struct called folder).
Code:
sprintf(folder[1].strpoints, "%ld", gainpts); /*load average #*/
length = strlen(folder[1].strpoints); /*into string & get it's*/
/*length for a pretty print*/
commnum = length / 4; /* commnum holds the number of comma's */
/* adds the padded spaces for right justified numbers */
for (j = 0; j < 12 - (length + commnum); j++) {
printf(" ");
//fprintf(out, " ");
}
/* digit is printed out first, then the comma, if needed */
for (n = 0, o = length; n < length; n++) {
printf(out, "%c", folder[1].strpoints[n]);
o--;
if (folder[1].strpoints[n] != ' ' && n % 3 == 0 && n > 0) { /*This is IT! %) */
printf("%c", ',');
//fprintf(out, "%c", ',');
}
}
Probably more work to do that than it was worth, but it did look nice.