Skip to content

gets() function, the gnu c compiler gives a warning that it is dangerous to use gets()

March 2, 2010

hey buddy hope everyone might be getting this error while performing pratical-1 of pc.

here is detail description with solution..

gets() does not allow you limit the amount of input, which means it
can potentially overflow the buffer into which the input is placed.

Because it cannot be used safely. There is no length control. Two
possible replacements for it are fgets() (a C standard function)
and ggets() (a non-standard function). ggets is available in
source form, with no restrictions, as at:


That function is deprecated and will disappear shortly.
Its usage is not recommended because there is no way to
limit the input that it will receive, and it can overflow
the input buffer.

i used fgets and it works fine.

If you find this article helpful, Please like our Facebook page.

Enjoy GNU/Linux




From → College, Computer

  1. anand permalink

    hey…. thanksss..

Trackbacks & Pingbacks

  1. 2010 in review « Tushar Sharma's Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: