This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gets is not too dangerous
- From: Michael Eager <eager at eagercon dot com>
- Cc: Miguel Angel Champin Catalan <mchampin at alumnos dot inf dot utfsm dot cl>, gcc at gcc dot gnu dot org
- Date: Fri, 01 Sep 2006 11:54:51 -0700
- Subject: Re: gets is not too dangerous
- References: <44F75A10.8060805@alumnos.inf.utfsm.cl> <44F880FE.1020307@eagercon.com>
Michael Eager wrote:
Miguel Angel Champin Catalan wrote:
Hello:
We are students of computer sciences in the Santa Maria University,
Chile. We just want to know if the function "gets" it's too dangerous
for a warning. The fact is that our teacher's assistant give us a
homework, and one restriction was to use gcc to compile our code,
without warnings.
We ask you for a simple explanation (if it's possible) about our
warning, telling that "gets" is not too dangerous, because in our
case, works perfectly, under some restrictions obviously.
Instead of using gets(), use fgets(). It's similar in function
and easy to use, but doesn't permit overwriting the input buffer.
^^^^^^^^^^^
overrunning
As a university student, I would hope that you would want to
learn the best way to do a task. Your teacher's assistant
seems to be encouraging you to use best practices. The difference
between poor practice and good practice usually comes down to that
poor practice "works perfectly, in our case, under some restrictions",
while good practice just "works perfectly".
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077