Another on String

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdINo
    New Member
    • Oct 2006
    • 11

    Another on String

    In string what is the difference between

    1 gets and scanf
    2 puts and printf
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    puts writes a string to stdout and appends a '\n', it does not format the string it has a fixed prototype

    printf writes data to stdout, it doesn't automatically append a '\n' and it can write formated data, that is you can give it a format string and binary data and it will put the binary data into the output in the correct format.

    gets and scanf act in a similar manor for input, however they are both unsafe functions. You shouldn't use either of them, instead use fgets.

    Comment

    Working...