I want to put commas into float like this: input: 12345.678 output: $12,345.678
I have seen a solution using char[] to solve this problem, but how can I do if I only want to use float?
#include<stdio.h>
#include<stdlib.h>
int main(void){
double num;
printf("Please enter a float: ");
scanf("%lf", &num);
do{
num/=1000;
}
while(num >= 1000);
printf("$%f",num);
system("PAUSE");
return 0;
}
These are the code I have done, and of course, it did not work in the way I want.
Sorry for poor English and programming skill.