Click here to Skip to main content
16,016,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: printf and commas Pin
Chris Losinger22-May-02 6:54
professionalChris Losinger22-May-02 6:54 
GeneralRe: printf and commas Pin
Romeozulu22-May-02 7:03
Romeozulu22-May-02 7:03 
GeneralRe: printf and commas Pin
Joaquín M López Muñoz22-May-02 6:57
Joaquín M López Muñoz22-May-02 6:57 
GeneralRe: printf and commas Pin
Romeozulu22-May-02 7:07
Romeozulu22-May-02 7:07 
GeneralRe: printf and commas Pin
Joaquín M López Muñoz22-May-02 7:29
Joaquín M López Muñoz22-May-02 7:29 
GeneralRe: printf and commas Pin
Michael Dunn22-May-02 19:07
sitebuilderMichael Dunn22-May-02 19:07 
GeneralRe: printf and commas Pin
Romeozulu23-May-02 5:07
Romeozulu23-May-02 5:07 
GeneralRe: printf and commas Pin
25-May-02 0:45
suss25-May-02 0:45 
you can use the following function; it's not mine and I havent tried it to be honest but it looks persuasive "
// Function inputs a num with commas every 3 places
// e.g. for 1000, add_commas prints 1,000
//
// Program uses recursion (non tail end)z
#include <iostream.h>
void add_commas(int num,int count)


{
if(num < 10)


{
cout << num << endl; // num by now only 1 digit
return;
}
else


{
count++; // count=count+1
if(count%3==0)


{
add_commas(num/10,count); // recursive call
cout << ',' << num%10; // cout comma then remainder of
// num / 10
}
else


{
add_commas(num/10,count); // recursive call
cout << num%10; // no comma just remainder of num/10
}
}
}
void main(void)


{
add_commas(123456789,0); // call add_commas (second param must be 0!)

}

Cool | :cool:

try it you will lose nothing
GeneralNewbie Need Help : Set font color, style, etc... Pin
22-May-02 6:13
suss22-May-02 6:13 
GeneralRe: Newbie Need Help : Set font color, style, etc... Pin
Jason Henderson22-May-02 6:18
Jason Henderson22-May-02 6:18 
GeneralRe: Newbie Need Help : Set font color, style, etc... Pin
22-May-02 6:18
suss22-May-02 6:18 
GeneralVC++ and Database Pin
Shayna22-May-02 5:36
Shayna22-May-02 5:36 
GeneralCSpinButtonCtrl Pin
Rage22-May-02 4:53
professionalRage22-May-02 4:53 
GeneralRe: CSpinButtonCtrl Pin
Rage22-May-02 5:15
professionalRage22-May-02 5:15 
GeneralRe: CSpinButtonCtrl Pin
Alex Cramer22-May-02 16:46
Alex Cramer22-May-02 16:46 
GeneralRe: CSpinButtonCtrl Pin
Michael Dunn22-May-02 19:11
sitebuilderMichael Dunn22-May-02 19:11 
GeneralRe: CSpinButtonCtrl Pin
Alex Cramer22-May-02 20:34
Alex Cramer22-May-02 20:34 
GeneralDialog Box Precise Location. Pin
DeepBlue22-May-02 4:44
DeepBlue22-May-02 4:44 
GeneralRe: Dialog Box Precise Location. Pin
Chris Losinger22-May-02 4:53
professionalChris Losinger22-May-02 4:53 
GeneralRe: Dialog Box Precise Location. Pin
DeepBlue22-May-02 4:52
DeepBlue22-May-02 4:52 
GeneralRe: Dialog Box Precise Location. Pin
Chris Losinger22-May-02 5:08
professionalChris Losinger22-May-02 5:08 
GeneralRe: Dialog Box Precise Location. Pin
Carlos Antollini22-May-02 5:14
Carlos Antollini22-May-02 5:14 
GeneralRe: Dialog Box Precise Location. Pin
Rage22-May-02 5:20
professionalRage22-May-02 5:20 
GeneralRe: Dialog Box Precise Location. Pin
Carlos Antollini22-May-02 5:32
Carlos Antollini22-May-02 5:32 
GeneralRe: Dialog Box Precise Location. Pin
Rage22-May-02 4:58
professionalRage22-May-02 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.