gets is not too dangerous
Michael Eager
eager@eagercon.com
Fri Sep 1 18:55:00 GMT 2006
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
More information about the Gcc
mailing list