NO

Author Topic: gets  (Read 3480 times)

JimJoyce

  • Guest
gets
« on: January 23, 2014, 03:11:41 PM »
Is there a problem with stdio.h? Or is it just gets()?
When I use gets() the compiler throws a warning #2018:
Undeclared function 'gets;' assuming 'extern' returning 'int'.

If I add my own prototype: ' char* gets ( char* );'  it compiles OK.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: gets
« Reply #1 on: January 23, 2014, 03:53:08 PM »
Is there a problem with stdio.h? Or is it just gets()?
When I use gets() the compiler throws a warning #2018:
Undeclared function 'gets;' assuming 'extern' returning 'int'.
Use compiler -std:C99 and you see 'warning #2241: The function 'gets' is marked as deprecated.'
PellesC isn't C89 compiler.
Quote
Compatibility
The most recent revision of the C standard (2011) has definitively removed this function from its specification.
The function is deprecated in C++ (as of 2011 standard, which follows C99+TC3).
« Last Edit: January 23, 2014, 03:55:08 PM by timovjl »
May the source be with you

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: gets
« Reply #2 on: January 24, 2014, 03:05:29 AM »
To add to timovjl's reply, see the "notes" part on this page:

http://en.cppreference.com/w/c/io/gets

Ralf