德$ P $名单pcated C函数? [英] List of deprecated C functions?

查看:123
本文介绍了德$ P $名单pcated C函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C小白,我刚刚发现的atoi是赞成与strtol等pcated德$ P $。

I'm a C noob and I just found out that atoi is deprecated in favor of strtol etc.

我在哪里可以找到德$ P $列表pcated C函数?

Where can I find a list of deprecated C functions ?

推荐答案

还有的不安全的之间的差异和德precated 的。 的atoi()是不安全的,但GCC是不会告诉你停止使用它,因为它的危险。使用得到()产生不同的结果 :) YCMV(你的编译器可能会有所不同)。

There's a difference between unsafe and deprecated. atoi() is unsafe, however gcc is not going to tell you to stop using it because its 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.

后者是更容易只是函数原型来确定。但是,如果你有点意识到自己在做什么,你很快就会意识到,你不知道,如果你从的atoi有什么方式()真是字符串重结果的presentation,用户只需在命令行上输入。

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.

这理由根本不全部排至标准C库。你会遇到很多很多的库code的,它的一些不错。没有名单可以替代了解到,防御性的编码习惯。

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.

这篇关于德$ P $名单pcated C函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆