#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    35
    Rep Power
    2

    Whers is gets defined in library in gcc


    In turbo c it is in string.h.
    Where is it located in gcc compiler?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    India
    Posts
    95
    Rep Power
    4
    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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    35
    Rep Power
    2
    but when i use gets, i get a warning of 'gets is deprecated'.
    what i needed to do for removing this?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    but when i use gets, i get a warning of 'gets is deprecated'.
    what i needed to do for removing this?
    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.

    Jim

    Comments on this post

    • eramit2010 agrees
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,173
    Rep Power
    2222
    Originally Posted by aswinas
    but when i use gets, i get a warning of 'gets is deprecated'.
    what i needed to do for removing this?
    By not using gets.

    Originally Posted by old joke
    "Doc, it hurts when I raise my arm like this!"
    "Well then don't raise your arm like that."
    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.

    RTFM.

    PS
    At least you are doing well by not ignoring warnings. Good choice! Warnings are more important than error messages. Never ignore warnings.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    35
    Rep Power
    2
    Thank you.
    I will stop using gets.
    I think fgets is a good option.
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,173
    Rep Power
    2222
    Good choice.

    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.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    35
    Rep Power
    2
    Thanks bro for explaining the fgets in detail.

IMN logo majestic logo threadwatch logo seochat tools logo