gets and puts warning

P

pavunkumar

Dear Friends:

Can you explained this things
while using gets and puts, compiler saying warning why
fput.c:(.text+0x2a3): warning: the `gets' function is dangerous and
should not be used.
 
B

Ben Pfaff

pavunkumar said:
Can you explained this things
while using gets and puts, compiler saying warning why
fput.c:(.text+0x2a3): warning: the `gets' function is dangerous and
should not be used.

This is in the FAQ.

12.23: Why does everyone say not to use gets()?

A: Unlike fgets(), gets() cannot be told the size of the buffer
it's to read into, so it cannot be prevented from overflowing
that buffer. As a general rule, always use fgets(). See
question 7.1 for a code fragment illustrating the replacement of
gets() with fgets().

References: Rationale Sec. 4.9.7.2; H&S Sec. 15.7 p. 356.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top