Thread: Delete last Character (comma) ?

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    104

    Unhappy Delete last Character (comma) ?

    I had to output a series of numbers with
    Code:
     printf ("%d,")
    but the last number will have the , after it. How do I delete that last comma? By the way the printf code is in a loop.

  2. #2
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    How about putting the comma into a different printf statement that does not get executed for the last item?
    Demonographic rhinology is not the only possible outcome, but why take the chance

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    An idea (' ' -> ',').
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Delete Function in Doubly Linked List
    By Dampecram in forum C Programming
    Replies: 5
    Last Post: 11-15-2008, 04:30 PM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 08:11 PM
  4. pipe
    By smart girl in forum C Programming
    Replies: 4
    Last Post: 04-30-2006, 09:17 AM
  5. Problem need help
    By Srpurdy in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2002, 12:45 PM