scanf(), gets() and fgets(). What’s the difference?

Asked

Viewed 45 times

3

Good afternoon to all,

I was studying some algorithms in C [especially Strings] and I couldn’t help noticing that fgets()and scanf() for reading strings often, but rarely use the gets() [Which is even accused by some compilers as 'not safe']. I would like, if possible, that some of my doubts were resolved

  • What is the difference between the 3 in running time.
  • What is the reason for using the fgets() that the gets() for strings.
  • Because the gets() is considered a "unsafe".
  • fgets() or scanf(), what is the most appropriate for string handling?

Thank you in advance for your attention.

P.S.: If it has not been clear so far my doubt, please signal so that I can correct.

  • 2

    This https://answall.com/q/42981/101?

  • 1

    Exactly that, thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.