C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 5th, 2005, 11:11 AM
firewall firewall is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 firewall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Little help plz

Hi,

Anybody here knows if there is some C/C++ code to "organize" numbers.
Like: 1234567 and than i get: 1.234.567

Thanks,
firewall

Reply With Quote
  #2  
Old January 5th, 2005, 03:16 PM
XZminX XZminX is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Varaždin, Croatia
Posts: 5 XZminX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to XZminX Send a message via AIM to XZminX Send a message via MSN to XZminX
People ca't help you if you dont describe your problem precisely.
If the "organising" is always the same and the number is always of same lenght (like date): X.XXX.XXX (X are digits) then that's no problem.
Just print the dot after ceratin number of digits (after first and fourth, and so on if you need)
Say if you need the complete code.
Tip: You may want to convert an integer to string for easier counting of numbers.

Reply With Quote
  #3  
Old January 5th, 2005, 03:37 PM
reorx reorx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 reorx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
there is no such a function.
In printf function there is a lot of options you can use with number formatting, but there is no functionality you need.
Check manual for printf (like: http://www.cplusplus.com/ref/cstdio/printf.html ).

to print the number as you showed you should write it manually:

Code:
 
void printnum(int num) 


{
if(num<0) { printf("-");num = -num; } int divisor = 1000000000; while(divisor>num) divisor = divisor/1000; int part;while(divisor>1000) { part=num/divisor;printf("%d.",part); num = num - part*divisor; divisor = divisor/1000;} printf("%d",num);
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Little help plz


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT