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 ggets.zip at:

<http://cbfalconer.home.att.net/download/&gt;

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

Use FOSS

–tushar

Advertisement

From → College, Computer

2 Comments
  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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: