C++中stdio.h与cstdio的区别

iceman19860106 2008-11-12 01:25:00
在C++中可以 #include <stdio.h>
也可以 #Icndlue <cstdio>
请问cstdio与stdio.h有什么区别?cstdio对stdio.h有什么优化吗?
为什么C++标准库中的头文件大多数都不包含.h比如<iostream>
为什么要这样做呢?
...全文
6797 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
陈某某418 2011-12-11
  • 打赏
  • 举报
回复
明白了,受教
  • 打赏
  • 举报
回复
貌似有点明白了
fulei06052146 2011-07-09
  • 打赏
  • 举报
回复
貌似明白了
haunglin10123 2011-05-14
  • 打赏
  • 举报
回复
路过的 貌似有点明白了
wczxwander 2010-12-08
  • 打赏
  • 举报
回复
原来如此~
概念得清楚啊……
nehc 2010-12-08
  • 打赏
  • 举报
回复
迷惑的看看,似懂非懂 的路过 ....
sunkehappy 2009-04-03
  • 打赏
  • 举报
回复
学习了一下,受教!
BaihowFF 2008-11-12
  • 打赏
  • 举报
回复
C++为了兼容纯C的语法所有有.h可以加...但是如果混用会有麻烦...你可以用你熟悉的函数分别试试...
建议在C++养成如下的习惯

#include <iostream>
#include <cstring>
#include <cstdio>
#include <c....>

using namespace XXX;//一般写写小东西都是std...大东西就没准了
user_csc 2008-11-12
  • 打赏
  • 举报
回复
vc98\include\iosfwd
Longinc 2008-11-12
  • 打赏
  • 举报
回复
一个是C++版本 一个是C版本
ssy2008 2008-11-12
  • 打赏
  • 举报
回复 1
cstdio是c++从C的stdio.h继承来的,在前面加C同时不要H后缀,在C++环境当然是选用前者,
两者内容都一样,只是cstdio头文件中定义的名字被定义在命名空间std中。这样使用后者就会带来额外的负担,你必须区分哪些
标准库明是C++特有的,哪些是继承过来的!!所以在C++中要尽量避免C风格的出现!!
sc_valentine21 2008-11-12
  • 打赏
  • 举报
回复
这是个标准的问题
星羽 2008-11-12
  • 打赏
  • 举报
回复
这个是cstdio的内容,看了你就明白了


// cstdio standard header
#pragma once
#ifndef _CSTDIO_
#define _CSTDIO_
#include <yvals.h>

#ifdef _STD_USING
#undef _STD_USING
#include <stdio.h>
#define _STD_USING

#else /* _STD_USING */
#include <stdio.h>
#endif /* _STD_USING */

#define _HAS_CONVENTIONAL_CLIB 1

#define _IOBASE _base
#define _IOPTR _ptr
#define _IOCNT _cnt

#ifndef RC_INVOKED
#if _GLOBAL_USING
_STD_BEGIN
using ::size_t; using ::fpos_t; using ::FILE;
using ::clearerr; using ::fclose; using ::feof;
using ::ferror; using ::fflush; using ::fgetc;
using ::fgetpos; using ::fgets; using ::fopen;
using ::fprintf; using ::fputc; using ::fputs;
using ::fread; using ::freopen; using ::fscanf;
using ::fseek; using ::fsetpos; using ::ftell;
using ::fwrite; using ::getc; using ::getchar;
using ::gets; using ::perror;
using ::putc; using ::putchar;
using ::printf; using ::puts; using ::remove;
using ::rename; using ::rewind; using ::scanf;
using ::setbuf; using ::setvbuf; using ::sprintf;
using ::sscanf; using ::tmpfile; using ::tmpnam;
using ::ungetc; using ::vfprintf; using ::vprintf;
using ::vsprintf;
_STD_END
#endif /* _GLOBAL_USING */
#endif /* RC_INVOKED */

#ifndef _Filet
#define _Filet FILE
#endif /* _Filet */

#ifndef _FPOSOFF
#define _FPOSOFF(fp) ((long)(fp))
#endif /* _FPOSOFF */

#endif /* _CSTDIO_ */

/*
* Copyright (c) 1992-2005 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V4.05:0009 */

65,182

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧