stdio.h不是C ++中的标准? [英] stdio.h not standard in C++?

查看:156
本文介绍了stdio.h不是C ++中的标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道大多数编译器允许两者:

  #include< stdio.h> 

//和

  #include< cstdio> 

但有人认为< stdio.h>

解决方案



stdio.h 是标准,但已弃用。


[n3290: C.3.1 / 1]:为了与标准C库兼容,
C ++标准库提供了18 C头(D.5),但它们的使用是$ b



[n3290:D.5 / 3]: em> 标题< cstdlib> 确保
在命名空间中提供其声明和定义 std 。它
也可以在全局命名空间中提供这些名称。 标题
< stdlib.h> 在全局命名空间中提供了相同的声明和定义
,与C标准。也可以
在命名空间 std 中提供这些名称。
-end example ]



I know most compilers allow both:

#include <stdio.h>

//and

#include <cstdio>

But someone argued that <stdio.h> is not actually C++ standard.

is that true?

解决方案

stdio.h is standard, but deprecated. Always prefer cstdio in C++.

[n3290: C.3.1/1]: For compatibility with the Standard C library, the C++ standard library provides the 18 C headers (D.5), but their use is deprecated in C++.

[n3290: D.5/3]: [ Example: The header <cstdlib> assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std. —end example ]

这篇关于stdio.h不是C ++中的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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