浅谈stdio.h及cstdio的区别

在C语言中,stdio.h 头文件是主要的。而在后来的C++语言中,C只是C++的一个子集,且C++中,已不推荐再用C的类库,但为了对已有代码的保护,还是对原来的头文件支持。

cstdio是c++从C的stdio.h继承来的,在前面加C同时不要H后缀,在C++环境当然是选用前者,两者内容都一样,只是cstdio头文件中定义的名字被定义在命名空间std中。使用后者就会带来额外的负担,需要区分哪些是
标准库明是C++特有的,哪些是继承过来的!!所以在C++中要尽量避免C风格的出现!!

cstdio code:
// 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 
#include <stdio.h>
#endif 

#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 
#endif 

#ifndef _Filet
#define _Filet    FILE
#endif 

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

#endif 

原文地址

stdio.c是一个C语言源文件,其中包含了与标准输入输出相关的函数的实现代码。而stdio.h是一个C语言头文件,其中包含了与标准输入输出相关的函数的声明。 在编写C语言程序时,我们可以通过包含<stdio.h>头文件来引入标准输入输出函数的声明,以便在程序中使用这些函数。这样可以提前告知编译器这些函数的存在,以便在编译期间进行语法检查类型检查。而通过链接器,我们可以把stdio.c中的函数实现与我们的程序进行链接,使其能够正常运行。这样我们就可以在程序中使用诸如printf、scanf等函数来进行输入输出操作了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [stdio.h 库函数下载](https://download.csdn.net/download/jian8182/11122463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [浅谈stdio.h及cstdio区别](https://blog.csdn.net/weixin_34320724/article/details/92895224)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [C/C++笔试必须熟悉掌握的头文件系列(一)——stdio.h/cstdio](https://blog.csdn.net/FX677588/article/details/52957601)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值