I'm a C noob and I just found out that atoi is deprecated in favor of strtol etc.
Where can I find a list of deprecated C functions ?
Deprecated attribute in C++14 with Examples Deprecated means the use of the name or entity declared with this attribute is allowed but discouraged for some reason. The compiler gives warnings and if string literals are provided, they are included in warnings.
Deprecated means they don't recommend using it, and that it isn't undergoing further development. But it should not work differently than it did in a previous version unless documentation explicitly states that.
There's a difference between unsafe and deprecated. atoi()
is unsafe, however gcc is not going to tell you to stop using it because it's dangerous. Using gets() produces a different result :) YCMV (your compiler may vary).
In general, if a function can fail and no error checking is possible, don't use it. If a function lets you write to a region of memory with out being able to pass a size limit, don't use it.
The latter is easier to determine just by the function prototype. However, if you are somewhat conscious of what you are doing, you'll quickly realize that you have no way of knowing if what you got from atoi()
was really the string representation of the result that a user just entered on the command line.
This rationale is not at all exclusive to the standard C library. You will encounter lots and lots of library code, some of it good. No list can replace learned, defensive coding habits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With