PDA

View Full Version : Compiling C in Bash


richanderson1984
January 29th, 2009, 05:37 PM
I'm new to both programming and Linux, so please bear with me. I've started off with C, and have been compiling using the following command:

gcc -o filename filename.c

However, when I input the gets() function into source code, I receive the following warning message from Ubuntu:

filename.c:(.text+0x54): warning: the 'gets' function is dangerous and should not be used.

How do I bypass this warning message? Any help would be much appreciated.

Thanks,
Richard

cmay
January 29th, 2009, 05:44 PM
i would heed the warning and start using fgets instead. here is a link to the description of it. gets is not so good as it can course bufferoverflows pretty easy. http://www.cplusplus.com/reference/clibrary/cstdio/fgets.html

its been a while since i did any c last so i may remember wrong but i am sure gets is not safe to use anyhow.
good luck to you.

richanderson1984
January 29th, 2009, 06:01 PM
Thanks, this worked like a treat :)

cmay
January 29th, 2009, 07:42 PM
no problem . glad to help and welcome to the forums by the way .

Tek-E
February 19th, 2009, 02:02 PM
no problem . glad to help and welcome to the forums by the way .

Doesnt gets() leave a greater possibility for the chance of a buffer overflow?