Neeladri Vishweswaran Neeladri Vishweswaran - 1 year ago 133
C Question

List of deprecated C functions?

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 ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download