LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-09-2004, 06:14 PM   #1
eastsuse
Member
 
Registered: Dec 2003
Location: Pacific Palisades
Distribution: Suse 9.0
Posts: 48

Rep: Reputation: 15
printf output with commas


I want to output a number using the printf function in the following way:


1,000,000.00.

Essentially, I would like a number with commas.

I can't find it anywhere in the printf documentation. does someone have a solution or do I need to make a custom function. J
 
Old 03-09-2004, 07:26 PM   #2
evilmrhenry
Member
 
Registered: Oct 2003
Distribution: Knoppix
Posts: 103

Rep: Reputation: 15
Well, since you didn't include the language you are using, I am assuming you're using C.

In short, it is not included in the C printf function, but it shouldn't be too hard to make. Either look around for a library that allows it or roll your own.

If you roll your own, just figure out the length of the number, and insert the commas at the right places.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
printf: postion cursor to output columns schneidz Programming 5 09-20-2005 08:59 AM
Output problems with printf pateldenish Programming 1 02-24-2005 09:02 AM
Samba - no commas in filenames? tisource Linux - Networking 5 03-18-2004 05:17 PM
printf new_user10 Programming 3 09-09-2003 11:12 PM
bash printf anyone? gumby Programming 4 05-13-2003 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration