Puts() or Printf() ?

This is a discussion on Puts() or Printf() ? within the C Programming forums, part of the General Programming Boards category; I've been review these two functions frantically. I've written numberous programs replacing printf with puts and it does the same ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    53

    Puts() or Printf() ?

    I've been review these two functions frantically. I've written numberous programs replacing printf with puts and it does the same output. I know puts is for displaying strings, but other than that why would I use puts instead of printf or vise versa?

    Hern

  2. #2
    .........
    Join Date
    Nov 2002
    Posts
    303
    puts() also prints a newline character at the end. Sometimes its easier to type
    puts("Hello World!"); than
    printf("Hello World!\n"); Only a two keystroke difference though hehe.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by SourceCode
    puts() also prints a newline character at the end. Sometimes its easier to type
    puts("Hello World!"); than
    printf("Hello World!\n"); Only a two keystroke difference though hehe.
    Four actually. "puts" is shorter than "printf" by two characters.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    .........
    Join Date
    Nov 2002
    Posts
    303
    Originally posted by quzah
    Four actually. "puts" is shorter than "printf" by two characters.

    Quzah.
    LOL

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    Originally posted by SourceCode
    puts() also prints a newline character at the end. Sometimes its easier to type
    puts("Hello World!"); than
    printf("Hello World!\n"); Only a two keystroke difference though hehe.
    Wha? I can save 11 keystrokes!

    puts("Hi!");

    //edit: Is printf() likely to use puts() in its implementation?
    Last edited by ygfperson; 06-24-2003 at 09:26 PM.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Is printf() likely to use puts() in its implementation?
    puts() outputs a newline character, so I doubt it.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. segmentation fault upon reload
    By yabud in forum C Programming
    Replies: 8
    Last Post: 12-18-2006, 06:54 AM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 09:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 11:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21