stdio.h


stdio.h

文章插图
stdio.h一般地,在C语言或C++中,会把用来#include的档案的扩展名叫 .h,称其为头档案 。#include档案的目的就是把多个编译单元(也就是c或者cpp档案)公用的内容,单独放在一个档案里减少整体代码尺寸;或者提供跨工程公共代码 。在现行的c++版本中,套用这个头档案应是#include<stdio.h>
基本介绍中文名:跨工程公共代码
外文名:stdio.h
目的:多个编译单元
提供:跨工程公共代码
简介stdio 就是指 “standard input & output"(标準输入输出)
stdio.h

文章插图
所以,原始码中如用到标準输入输出函式时,就要包含这个头档案!例如c语言中的 printf("%d",i); scanf("%d",&i);等函式 。引用方法#include <stdio.h>(注:在TC2.0中,允许不引用此头档案而直接调用其中的函式,但这种做法是不标準的 。也不建议这样做 。以避免出现在其他IDE中无法编译或执行的问题 。)标準函式int getchar()//从标準输入设备写入一个字元int putchar()//向标準输出设备读出一个字元int scanf(char*format[,argument…])//从标準输入设备读入格式化后的数据int printf(char*format[,argument…])//向标準输出设备输出格式化字元串char* gets(char*string)//从标準输入设备读入一个字元串int puts(char*string)//向标準输出设备输出一个字元串int sprintf(char*string,char*format[,…])//把格式化的数据写入某个字元串缓冲区档案内容档案说明/**stdio.h*ThisfilehasnocopyrightassignedandisplacedinthePublicDomain.*Thisfileisapartofthemingw-runtimepackage.*Nowarrantyisgiven;refertothefileDISCLAIMERwithinthepackage.**Definitionsoftypesandprototypesoffunctionsforstandardinputand*output.**NOTE:ThefilemanipulationfunctionsprovidedbyMicrosoftseemto*workwitheitherslash(/)orbackslash(\)asthedirectoryseparator.**/宏定义【stdio.h】#ifndef_STDIO_H_#define_STDIO_H_/*Alltheheadersincludethisfile.*/#include<_mingw.h>#ifndefRC_INVOKED#define__need_size_t#define__need_NULL#define__need_wchar_t#define__need_wint_t#include<stddef.h>#define__need___va_list#include<stdarg.h>#endif/*NotRC_INVOKED*//*Flagsfortheiobufstructure*/#define_IOREAD1/*currentlyreading*/#define_IOWRT2/*currentlywriting*/#define_IORW0x0080/*openedas"r+w"*//**Thethreestandardfilepointersprovidedbytheruntimelibrary.*NOTE:Thesewillgotothebit-bucketsilentlyinGUIapplications!*/#defineSTDIN_FILENO0#defineSTDOUT_FILENO1#defineSTDERR_FILENO2/*Returnedbyvariousfunctionsonendoffileconditionorerror.*/#defineEOF(-1)/**Themaximumlengthofafilename.YoushoulduseGetVolumeInformation*insteadofthisconstant.Buthey,thisworks.*Alsodefinedinio.h.*/#ifndefFILENAME_MAX#defineFILENAME_MAX(260)#endif/**Themaximumnumberoffilesthatmaybeopenatonce.Ihavesetthisto*aconservativenumber.Theactualvaluemaybehigher.*/#defineFOPEN_MAX(20)/*Aftercreatingthismanynames,tmpnamandtmpfilereturnNULL*/#defineTMP_MAX32767/**Tmpnam,tmpfileand,sometimes,_tempnamtrytocreate*tempfilesintherootdirectoryofthecurrentdrive*(notinpwd,assuggestedbysomeolderMSdoc's).*RedefiningthesemacrosdoesnoteffecttheCRTfunctions.*/#define_P_tmpdir"\\"#ifndef__STRICT_ANSI__#defineP_tmpdir_P_tmpdir#endif#define_wP_tmpdirL"\\"/**Themaximumsizeofname(includingNUL)thatwillbeputintheuser*suppliedbuffercaNamefortmpnam.*Inferredfromthesizeofthestaticbufferreturnedbytmpnam*whenpassedaNULLargument.Mayactuallybesmaller.*/#defineL_tmpnam(16)#define_IOFBF0x0000/*fullbuffered*/#define_IOLBF0x0040/*linebuffered*/#define_IONBF0x0004/*notbuffered*/#define_IOMYBUF0x0008/*stdiomalloc()'dbuffer*/#define_IOEOF0x0010/*EOFreachedonread*/#define_IOERR0x0020/*I/Oerrorfromsystem*/#define_IOSTRG0x0040/*Strangeornofiledescriptor*/#ifdef_POSIX_SOURCE#define_IOAPPEND0x0200#endif/**Thebuffersizeasusedbysetbufsuchthatitisequivalentto*(void)setvbuf(fileSetBuffer,caBuffer,_IOFBF,BUFSIZ).*/#defineBUFSIZ512/*ConstantsfornOriginindicatingthepositionrelativetowhichfseek*setsthefileposition.Enclosedinifdefsbecauseio.hcouldalso*definethem.(Thoughnotanymoresinceio.hincludesthisfilenow.)*/#ifndefSEEK_SET#defineSEEK_SET(0)#endif#ifndefSEEK_CUR#defineSEEK_CUR(1)#endif#ifndefSEEK_END#defineSEEK_END(2)#endif#ifndefRC_INVOKED#ifndef__VALIST#ifdef__GNUC__#define__VALIST__gnuc_va_list#else#define__VALISTchar*#endif#endif/*defined__VALIST*//**ThestructureunderlyingtheFILEtype.**Somebelievethatnobodyintheirrightmindshouldmakeuseofthe*internalsofthisstructure.ProvidedbyPedroA.ArandaGutiirrez*/#ifndef_FILE_DEFINED#define_FILE_DEFINED