Thread: Display with commas

  1. #1

    Display with commas

    I am writting a function displaywithcommas that accpepts any numer of perameters and is maxed out at a 10 digit numer. This is part of a caclulater program i am writting, and this is what the function should do.
    If you enter 1234567890 it should show 123,456,890.
    Help me please!

  2. #2

    learn it, use it, save up to 33%!!!!

  3. #3
    Registered User
    Join Date
    Aug 2001
    If you plan to output the variable all at once it can't be a numeric variable since it has commas in it. Therefore accept input as a char array. reverse the array with strrev() or write your own reversal funcution. Use a loop to advance down the array one element at a time. Use a counter to keep track of how many steps have been taken. After every third step move all data remaining in array after current index one spot to the right starting with the null operator and working back to desired location. Once desired location is open put a comma in it, jump over the comma and start counting out another three steps. When all commas have been entered reverse the string again and display the result.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. display character size...(quite urgent..)
    By karthi in forum C Programming
    Replies: 10
    Last Post: 07-11-2007, 09:42 PM
  2. new problem with class
    By jrb47 in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2006, 08:39 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Speeding Up Display Time in CEditView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-22-2002, 07:24 PM