[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Function strtodol - converts a string to dollar format
Syntax char *strtodol(char *source);
Prototype in stringhk.h
Remarks strtodol converts a string pointed to by source to
dollar format ($-12,839.44). An optional leading
sign is copied. Only the first 2 decimal places are
copied (the string is truncated, not rounded.)
Return value returns a pointer to the storage location
containing the dollar formatted string, or NULL if
space could not be allocated. The returned string
is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char sint[15], *dollar
strcpy(sint,"12839.44");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
free(dollar);
strcpy(sint,"+62939445.1");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
free(dollar);
}
Program output 12839.44 -> $12,839.44
+62939445.1 -> $+62,939,445.10
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson