Thread: URGENT (I need sleep) Simple question about formatting dollar numbers with printf

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    2

    URGENT (I need sleep) Simple question about formatting dollar numbers with printf

    How do I use printf to format an integer to look something like: $100,300,300 instead of 100300300?

    It's 2 AM and I have class tomorrow.. the sooner you can help the better.

    Thanks a ton.

  2. #2
    Registered User
    Join Date
    Oct 2004
    Posts
    2
    edit: float not integer

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > URGENT (I need sleep)
    You joined a message board just to announce that you need sleep?
    What do you do if your house is on fire - take out full page ads in a national newspaper?

    > It's 2 AM and I have class tomorrow
    while ( !sunrise ) { /* snooze */ }

    > How do I use printf to format an integer to look something like: $100,300,300 instead of 100300300?
    Use /1000 and %1000 to extract each group of digits.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > What do you do if your house is on fire - take out full page ads in a national newspaper?
    Hahahah!!!
    The world is waiting. I must leave you now.

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> It's 2 AM and I have class tomorrow..

    Little tip, start earlier.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    I'm am posting this because it appears that you are posting a homework assignment or other project and you are asking for someone else to do all of the work.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of the forum to see what is acceptable or PM me.

    Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.

    On obivous homework questions especially, I also like to remind people of the board's tenth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,

    Kermi3
    Lead Moderator
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. I have some questions :(
    By geekrockergal in forum C Programming
    Replies: 19
    Last Post: 02-01-2009, 09:44 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM