August 19th, 2013, 10:59 PM
Whers is gets defined in library in gcc
In turbo c it is in string.h.
Where is it located in gcc compiler?
August 19th, 2013, 11:30 PM
none of function are defined in header file.
only declaration of function is there any header file.
functions are defined in library and that will be linked at the linking stage of compilation.
gets function is declared in stdio.h
just read man page of any function and you will get which header files you need to include from that man page only.
August 19th, 2013, 11:37 PM
but when i use gets, i get a warning of 'gets is deprecated'.
what i needed to do for removing this?
August 19th, 2013, 11:38 PM
You really should forget you ever heard about gets(). This is a very dangerous function that can never be used safely and should never ever be used. By the way it is not only depreciated in C99 but has also been removed from the C11 standard.
Comments on this post
August 20th, 2013, 10:31 AM
By not using gets.
Originally Posted by aswinas
When you read the man page for gets, it will also inform you that gets is deprecated and will advise you what to do instead.
Originally Posted by old joke
At least you are doing well by not ignoring warnings. Good choice! Warnings are more important than error messages. Never ignore warnings.
August 20th, 2013, 11:50 PM
I will stop using gets.
I think fgets is a good option.
August 20th, 2013, 11:59 PM
Just be aware that they behave a bit differently:
gets gives you the entire line, but without the newline
fgets does the same, only with the newline character(s) ('\n')
When using fgets, if you need to have the newline removed, then you will need to do it yourself.
August 21st, 2013, 12:40 AM
Thanks bro for explaining the fgets in detail.