一般地,在C语言或C++中,会把用来#include的文件的扩展名叫 .h,称其为头文件。 #include文件的目的就是把多个编译单元(也就是c或者cpp文件)公用的内容,单独放在一个文件里减少整体代码尺寸;或者提供跨工程公共代码。

引用方法

#include <stdio.h>
(注:在TC2.0中,允许不引用此头文件而直接调用其中的函数,但这种做法是不标准的。也不建议这样做。以避免出现在其他IDE中无法编译或执行的问题。)[2] 
stdio 就是指 “standard input & output"(标准输入输出
所以,源代码中如用到标准输入输出函数时,就要包含这个头文件
例如c语言中的 printf("%d",i); scanf("%d",&i);等函数。

简介

stdio .h 头文件定义了三个变量类型、一些宏和各种函数来执行输入和输出。

库变量

下面是头文件 stdio.h 中定义的变量类型:

序号 变量 & 描述
1 size_t 
这是无符号整数类型,它是 sizeof 关键字的结果。
2 FILE 
这是一个适合存储文件流信息的对象类型。
3 fpos_t 
这是一个适合存储文件中任何位置的对象类型。

库宏

下面是头文件 stdio.h 中定义的宏:

序号 宏 & 描述
1 NULL
这个宏是一个空指针常量的值。
2 _IOFBF、_IOLBF 和 _IONBF 
这些宏扩展了带有特定值的整型常量表达式,并适用于 setvbuf 函数的第三个参数。
3 BUFSIZ
这个宏是一个整数,该整数代表了 setbuf 函数使用的缓冲区大小。
4 EOF 
这个宏是一个表示已经到达文件结束的负整数。
5 FOPEN_MAX 
这个宏是一个整数,该整数代表了系统可以同时打开的文件数量。
6 FILENAME_MAX 
这个宏是一个整数,该整数代表了字符数组可以存储的文件名的最大长度。如果实现没有任何限制,则该值应为推荐的最大值。
7 L_tmpnam 
这个宏是一个整数,该整数代表了字符数组可以存储的由 tmpnam 函数创建的临时文件名的最大长度。
8 SEEK_CUR、SEEK_END 和 SEEK_SET 
这些宏是在These macros are used in the fseek 函数中使用,用于在一个文件中定位不同的位置。
9 TMP_MAX 
这个宏是 tmpnam 函数可生成的独特文件名的最大数量。
10 stderr、stdin 和 stdout 
这些宏是指向 FILE 类型的指针,分别对应于标准错误、标准输入和标准输出流。

库函数

下面是头文件 stdio.h 中定义的函数:

为了更好地理解函数,请按照下面的序列学习这些函数,因为第一个函数中创建的文件会在后续的函数中使用到。

序号 函数 & 描述
1 int fclose(FILE *stream)
关闭流 stream。刷新所有的缓冲区。
2 void clearerr(FILE *stream)
清除给定流 stream 的文件结束和错误标识符。
3 int feof(FILE *stream)
测试给定流 stream 的文件结束标识符。
4 int ferror(FILE *stream)
测试给定流 stream 的错误标识符。
5 int fflush(FILE *stream)
刷新流 stream 的输出缓冲区。
6 int fgetpos(FILE *stream, fpos_t *pos)
获取流 stream 的当前文件位置,并把它写入到 pos。
7 FILE *fopen(const char *filename, const char *mode)
使用给定的模式 mode 打开 filename 所指向的文件。
8 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
从给定流 stream 读取数据到 ptr 所指向的数组中。
9 FILE *freopen(const char *filename, const char *mode, FILE *stream)
把一个新的文件名 filename 与给定的打开的流 stream 关联,同时关闭流中的旧文件。
10 int fseek(FILE *stream, long int offset, int whence)
设置流 stream 的文件位置为给定的偏移 offset,参数 offset 意味着从给定的 whence 位置查找的字节数。
11 int fsetpos(FILE *stream, const fpos_t *pos)
设置给定流 stream 的文件位置为给定的位置。参数 pos 是由函数 fgetpos 给定的位置。
12 long int ftell(FILE *stream)
返回给定流 stream 的当前文件位置。
13 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
把 ptr 所指向的数组中的数据写入到给定流 stream 中。
14 int remove(const char *filename)
删除给定的文件名 filename,以便它不再被访问。
15 int rename(const char *old_filename, const char *new_filename)
把 old_filename 所指向的文件名改为 new_filename。
16 void rewind(FILE *stream)
设置文件位置为给定流 stream 的文件的开头。
17 void setbuf(FILE *stream, char *buffer)
定义流 stream 应如何缓冲。
18 int setvbuf(FILE *stream, char *buffer, int mode, size_t size)
另一个定义流 stream 应如何缓冲的函数。
19 FILE *tmpfile(void)
以二进制更新模式(wb+)创建临时文件。
20 char *tmpnam(char *str)
生成并返回一个有效的临时文件名,该文件名之前是不存在的。
21 int fprintf(FILE *stream, const char *format, ...)
发送格式化输出到流 stream 中。
22 int printf(const char *format, ...)
发送格式化输出到标准输出 stdout。
23 int sprintf(char *str, const char *format, ...)
发送格式化输出到字符串。
24 int vfprintf(FILE *stream, const char *format, va_list arg)
使用参数列表发送格式化输出到流 stream 中。
25 int vprintf(const char *format, va_list arg)
使用参数列表发送格式化输出到标准输出 stdout。
26 int vsprintf(char *str, const char *format, va_list arg)
使用参数列表发送格式化输出到字符串。
27 int fscanf(FILE *stream, const char *format, ...)
从流 stream 读取格式化输入。
28 int scanf(const char *format, ...)
从标准输入 stdin 读取格式化输入。
29 int sscanf(const char *str, const char *format, ...)
从字符串读取格式化输入。
30 int fgetc(FILE *stream)
从指定的流 stream 获取下一个字符(一个无符号字符),并把位置标识符往前移动。
31 char *fgets(char *str, int n, FILE *stream)
从指定的流 stream 读取一行,并把它存储在 str 所指向的字符串内。当读取 (n-1) 个字符时,或者读取到换行符时,或者到达文件末尾时,它会停止,具体视情况而定。
32 int fputc(int char, FILE *stream)
把参数 char 指定的字符(一个无符号字符)写入到指定的流 stream 中,并把位置标识符往前移动。
33 int fputs(const char *str, FILE *stream)
把字符串写入到指定的流 stream 中,但不包括空字符。
34 int getc(FILE *stream)
从指定的流 stream 获取下一个字符(一个无符号字符),并把位置标识符往前移动。
35 int getchar(void)
从标准输入 stdin 获取一个字符(一个无符号字符)。
36 char *gets(char *str)
从标准输入 stdin 读取一行,并把它存储在 str 所指向的字符串中。当读取到换行符时,或者到达文件末尾时,它会停止,具体视情况而定。
37 int putc(int char, FILE *stream)
把参数 char 指定的字符(一个无符号字符)写入到指定的流 stream 中,并把位置标识符往前移动。
38 int putchar(int char)
把参数 char 指定的字符(一个无符号字符)写入到标准输出 stdout 中。
39 int puts(const char *str)
把一个字符串写入到标准输出 stdout,直到空字符,但不包括空字符。换行符会被追加到输出中。
40 int ungetc(int char, FILE *stream)
把字符 char(一个无符号字符)推入到指定的流 stream 中,以便它是下一个被读取到的字符。
41 void perror(const char *str)
把一个描述性错误消息输出到标准错误 stderr。首先输出字符串 str,后跟一个冒号,然后是一个空格。
  1. 标准函数
  1. int getchar()//从标准输入设备读入一个字符
  2. int putchar()//向标准输出设备写出一个字符
  3. int scanf(char*format[,argument…])//从标准输入设备读入格式化后的数据
  4. int printf(char*format[,argument…])//向标准输出设备输出格式化字符串
  5. char gets(char*string)//从标准输入设备读入一个字符串
  6. int puts(char*string)//向标准输出设备输出一个字符串
  7. int sprintf(char*string,char*format[,…])//把格式化的数据写入某个字符串缓冲区

文件内容

文件说明

  1. /*
  2. *stdio.h
  3. *ThisfilehasnocopyrightassignedandisplacedinthePublicDomain.
  4. *Thisfileisapartofthemingw-runtimepackage.
  5. *Nowarrantyisgiven;refertothefileDISCLAIMERwithinthepackage.
  6. *
  7. *Definitionsoftypesandprototypesoffunctionsforstandardinputand
  8. *output.
  9. *
  10. *NOTE:ThefilemanipulationfunctionsprovidedbyMicrosoftseemto
  11. *workwitheitherslash(/)orbackslash(\)asthedirectoryseparator.
  12. *
  13. */

宏定义

  1. #ifndef_STDIO_H_
  2. #define_STDIO_H_
  3. /*Alltheheadersincludethisfile.*/
  4. #include<_mingw.h>
  5. #ifndefRC_INVOKED
  6. #define__need_size_t
  7. #define__need_NULL
  8. #define__need_wchar_t
  9. #define__need_wint_t
  10. #include<stddef.h>
  11. #define__need___va_list
  12. #include<stdarg.h>
  13. #endif/*NotRC_INVOKED*/
  14. /*Flagsfortheiobufstructure*/
  15. #define_IOREAD1/*currentlyreading*/
  16. #define_IOWRT2/*currentlywriting*/
  17. #define_IORW0x0080/*openedas"r+w"*/
  18. /*
  19. *Thethreestandardfilepointersprovidedbytheruntimelibrary.
  20. *NOTE:Thesewillgotothebit-bucketsilentlyinGUIapplications!
  21. */
  22. #defineSTDIN_FILENO0
  23. #defineSTDOUT_FILENO1
  24. #defineSTDERR_FILENO2
  25. /*Returnedbyvariousfunctionsonendoffileconditionorerror.*/
  26. #defineEOF(-)
  27. /*
  28. *Themaximumlengthofafilename.YoushoulduseGetVolumeInformation
  29. *insteadofthisconstant.Buthey,thisworks.
  30. *Alsodefinedinio.h.
  31. */
  32. #ifndefFILENAME_MAX
  33. #defineFILENAME_MAX()
  34. #endif
  35. /*
  36. *Themaximumnumberoffilesthatmaybeopenatonce.Ihavesetthisto
  37. *aconservativenumber.Theactualvaluemaybehigher.
  38. */
  39. #defineFOPEN_MAX()
  40. /*Aftercreatingthismanynames,tmpnamandtmpfilereturnNULL*/
  41. #defineTMP_MAX32767
  42. /*
  43. *Tmpnam,tmpfileand,sometimes,_tempnamtrytocreate
  44. *tempfilesintherootdirectoryofthecurrentdrive
  45. *(notinpwd,assuggestedbysomeolderMSdoc's).
  46. *RedefiningthesemacrosdoesnoteffecttheCRTfunctions.
  47. */
  48. #define_P_tmpdir"\\"
  49. #ifndef__STRICT_ANSI__
  50. #defineP_tmpdir_P_tmpdir
  51. #endif
  52. #define_wP_tmpdirL"\\"
  53. /*
  54. *Themaximumsizeofname(includingNUL)thatwillbeputintheuser
  55. *suppliedbuffercaNamefortmpnam.
  56. *Inferredfromthesizeofthestaticbufferreturnedbytmpnam
  57. *whenpassedaNULLargument.Mayactuallybesmaller.
  58. */
  59. #defineL_tmpnam()
  60. #define_IOFBF0x0000/*fullbuffered*/
  61. #define_IOLBF0x0040/*linebuffered*/
  62. #define_IONBF0x0004/*notbuffered*/
  63. #define_IOMYBUF0x0008/*stdiomalloc()'dbuffer*/
  64. #define_IOEOF0x0010/*EOFreachedonread*/
  65. #define_IOERR0x0020/*I/Oerrorfromsystem*/
  66. #define_IOSTRG0x0040/*Strangeornofiledescriptor*/
  67. #ifdef_POSIX_SOURCE
  68. #define_IOAPPEND0x0200
  69. #endif
  70. /*
  71. *Thebuffersizeasusedbysetbufsuchthatitisequivalentto
  72. *(void)setvbuf(fileSetBuffer,caBuffer,_IOFBF,BUFSIZ).
  73. */
  74. #defineBUFSIZ512
  75. /*ConstantsfornOriginindicatingthepositionrelativetowhichfseek
  76. *setsthefileposition.Enclosedinifdefsbecauseio.hcouldalso
  77. *definethem.(Thoughnotanymoresinceio.hincludesthisfilenow.)*/
  78. #ifndefSEEK_SET
  79. #defineSEEK_SET()
  80. #endif
  81. #ifndefSEEK_CUR
  82. #defineSEEK_CUR()
  83. #endif
  84. #ifndefSEEK_END
  85. #defineSEEK_END()
  86. #endif
  87. #ifndefRC_INVOKED
  88. #ifndef__VALIST
  89. #ifdef__GNUC__
  90. #define__VALIST__gnuc_va_list
  91. #else
  92. #define__VALISTchar*
  93. #endif
  94. #endif/*defined__VALIST*/
  95. /*
  96. *ThestructureunderlyingtheFILEtype.
  97. *
  98. *Somebelievethatnobodyintheirrightmindshouldmakeuseofthe
  99. *internalsofthisstructure.ProvidedbyPedroA.ArandaGutiirrez
  100. */
  101. #ifndef_FILE_DEFINED
  102. #define_FILE_DEFINED

结构体定义

  1. typedefstruct_iobuf
  2. {
  3. char*_ptr;
  4. int_cnt;
  5. char*_base;
  6. int_flag;
  7. int_file;
  8. int_charbuf;
  9. int_bufsiz;
  10. char*_tmpfname;
  11. }FILE;
  12. #endif/*Not_FILE_DEFINED*/
  13. /*
  14. *Thestandardfilehandles
  15. */
  16. #ifndef__DECLSPEC_SUPPORTED
  17. externFILE(*_imp___iob)[];/*ApointertoanarrayofFILE*/
  18. #define_iob(*_imp___iob)/*AnarrayofFILE*/
  19. #else/*__DECLSPEC_SUPPORTED*/
  20. __MINGW_IMPORTFILE_iob[];/*AnarrayofFILEimportedfromDLL.*/
  21. #endif/*__DECLSPEC_SUPPORTED*/
  22. #definestdin(&_iob[STDIN_FILENO])
  23. #definestdout(&_iob[STDOUT_FILENO])
  24. #definestderr(&_iob[STDERR_FILENO])

操作函数定义

  1. #ifdef__cplusplus
  2. extern"C"{
  3. #endif
  4. /*
  5. *FileOperations
  6. */
  7. _CRTIMPFILE*__cdeclfopen(constchar*,constchar*);
  8. _CRTIMPFILE*__cdeclfreopen(constchar*,constchar*,FILE*);
  9. _CRTIMPint__cdeclfflush(FILE*);
  10. _CRTIMPint__cdeclfclose(FILE*);
  11. /*MSputsremove&rename(butnotwideversions)inio.halso*/
  12. _CRTIMPint__cdeclremove(constchar*);
  13. _CRTIMPint__cdeclrename(constchar*,constchar*);
  14. _CRTIMPFILE*__cdecltmpfile(void);
  15. _CRTIMPchar*__cdecltmpnam(char*);
  16. #ifndef__STRICT_ANSI__
  17. _CRTIMPchar*__cdecl_tempnam(constchar*,constchar*);
  18. _CRTIMPint__cdecl_rmtmp(void);
  19. #ifndefNO_OLDNAMES
  20. _CRTIMPchar*__cdecltempnam(constchar*,constchar*);
  21. _CRTIMPint__cdeclrmtmp(void);
  22. #endif
  23. #endif/*__STRICT_ANSI__*/
  24. _CRTIMPint__cdeclsetvbuf(FILE*,char*,int,size_t);
  25. _CRTIMPvoid__cdeclsetbuf(FILE*,char*);
  26. /*
  27. *FormattedOutput
  28. */
  29. _CRTIMPint__cdeclfprintf(FILE*,constchar*,...);
  30. _CRTIMPint__cdeclprintf(constchar*,...);
  31. _CRTIMPint__cdeclsprintf(char*,constchar*,...);
  32. _CRTIMPint__cdecl_snprintf(char*,size_t,constchar*,...);
  33. _CRTIMPint__cdeclvfprintf(FILE*,constchar*,__VALIST);
  34. _CRTIMPint__cdeclvprintf(constchar*,__VALIST);
  35. _CRTIMPint__cdeclvsprintf(char*,constchar*,__VALIST);
  36. _CRTIMPint__cdecl_vsnprintf(char*,size_t,constchar*,__VALIST);
  37. #ifndef__NO_ISOCEXT/*externsinlibmingwex.a*/
  38. int__cdeclsnprintf(char*s,size_tn,constchar*format,...);
  39. __CRT_INLINEint__cdecl
  40. vsnprintf(char*s,size_tn,constchar*format,__VALISTarg)
  41. {return_vsnprintf(s,n,format,arg);}
  42. int__cdeclvscanf(constchar*__restrict__,__VALIST);
  43. int__cdeclvfscanf(FILE*__restrict__,constchar*__restrict__,
  44. __VALIST);
  45. int__cdeclvsscanf(constchar*__restrict__,
  46. constchar*__restrict__,__VALIST);
  47. #endif
  48. /*
  49. *FormattedInput
  50. */
  51. _CRTIMPint__cdeclfscanf(FILE*,constchar*,...);
  52. _CRTIMPint__cdeclscanf(constchar*,...);
  53. _CRTIMPint__cdeclsscanf(constchar*,constchar*,...);
  54. /*
  55. *CharacterInputandOutputFunctions
  56. */
  57. _CRTIMPint__cdeclfgetc(FILE*);
  58. _CRTIMPchar*__cdeclfgets(char*,int,FILE*);
  59. _CRTIMPint__cdeclfputc(int,FILE*);
  60. _CRTIMPint__cdeclfputs(constchar*,FILE*);
  61. _CRTIMPchar*__cdeclgets(char*);
  62. _CRTIMPint__cdeclputs(constchar*);
  63. _CRTIMPint__cdeclungetc(int,FILE*);
  64. /*Traditionally,getcandputcaredefinedasmacros.butthe
  65. standarddoesn'tsaythattheymustbemacros.
  66. Weuseinlinefunctionsheretoallowthefastversions
  67. tobeusedinC++withnamespacequalification,eg.,::getc.
  68. _filbufand_flsbufarenotthread-safe.*/
  69. _CRTIMPint__cdecl_filbuf(FILE*);
  70. _CRTIMPint__cdecl_flsbuf(int,FILE*);
  71. #if!defined_MT
  72. __CRT_INLINEint__cdeclgetc(FILE*__F)
  73. {
  74. return(--__F->_cnt>=)
  75. ?(int)(unsignedchar)*__F->_ptr++
  76. :_filbuf(__F);
  77. }
  78. __CRT_INLINEint__cdeclputc(int__c,FILE*__F)
  79. {
  80. return(--__F->_cnt>=)
  81. ?(int)(unsignedchar)(*__F->_ptr++=(char)__c)
  82. :_flsbuf(__c,__F);
  83. }
  84. __CRT_INLINEint__cdeclgetchar(void)
  85. {
  86. return(--stdin->_cnt>=)
  87. ?(int)(unsignedchar)*stdin->_ptr++
  88. :_filbuf(stdin);
  89. }
  90. __CRT_INLINEint__cdeclputchar(int__c)
  91. {
  92. return(--stdout->_cnt>=)
  93. ?(int)(unsignedchar)(*stdout->_ptr++=(char)__c)
  94. :_flsbuf(__c,stdout);}
  95. #else/*Uselibraryfunctions.*/
  96. _CRTIMPint__cdeclgetc(FILE*);
  97. _CRTIMPint__cdeclputc(int,FILE*);
  98. _CRTIMPint__cdeclgetchar(void);
  99. _CRTIMPint__cdeclputchar(int);
  100. #endif
  101. /*
  102. *DirectInputandOutputFunctions
  103. */
  104. _CRTIMPsize_t__cdeclfread(void*,size_t,size_t,FILE*);
  105. _CRTIMPsize_t__cdeclfwrite(constvoid*,size_t,size_t,FILE*);
  106. /*
  107. *FilePositioningFunctions
  108. */
  109. _CRTIMPint__cdeclfseek(FILE*,long,int);
  110. _CRTIMPlong__cdeclftell(FILE*);
  111. _CRTIMPvoid__cdeclrewind(FILE*);
  112. #ifdef__USE_MINGW_FSEEK/*Theseareinlibmingwex.a*/
  113. /*
  114. *Workaroundforlimitationsonwin9xwhereafilecontentsare
  115. *notzero'doutifyouseekpasttheendandthenwrite.
  116. */
  117. int__cdecl__mingw_fseek(FILE*,long,int);
  118. int__cdecl__mingw_fwrite(constvoid*,size_t,size_t,FILE*);
  119. #definefseek(fp,offset,whence)__mingw_fseek(fp,offset,whence)
  120. #definefwrite(buffer,size,count,fp)__mingw_fwrite(buffer,size,count,fp)
  121. #endif/*__USE_MINGW_FSEEK*/
  122. /*
  123. *Anopaquedatatypeusedforstoringfilepositions...Thecontentsof
  124. *thistypeareunknown,butwe(thecompiler)needtoknowthesize
  125. *becausetheprogrammerusingfgetposandfsetposwillbesettingaside
  126. *storageforfpos_tstructres.ActuallyItestedusingabytearrayand
  127. *itisfairlyevidentthatthefpos_ttypeisalong(inCRTDLL.DLL).
  128. *Perhapsanunsignedlong?TODO?It'sdefinitelya64-bitnumberin
  129. *MSVCRThowever,andfornow`longlong'willdo.
  130. */
  131. #ifdef__MSVCRT__
  132. typedeflonglongfpos_t;
  133. #else
  134. typedeflongfpos_t;
  135. #endif
  136. _CRTIMPint__cdeclfgetpos(FILE*,fpos_t*);
  137. _CRTIMPint__cdeclfsetpos(FILE*,constfpos_t*);
  138. /*
  139. *ErrorFunctions
  140. */
  141. _CRTIMPint__cdeclfeof(FILE*);
  142. _CRTIMPint__cdeclferror(FILE*);
  143. #ifdef__cplusplus
  144. inlineint__cdeclfeof(FILE*__F)
  145. {return__F->_flag&_IOEOF;}
  146. inlineint__cdeclferror(FILE*__F)
  147. {return__F->_flag&_IOERR;}
  148. #else
  149. #definefeof(__F)((__F)->_flag&_IOEOF)
  150. #defineferror(__F)((__F)->_flag&_IOERR)
  151. #endif
  152. _CRTIMPvoid__cdeclclearerr(FILE*);
  153. _CRTIMPvoid__cdeclperror(constchar*);
  154. #ifndef__STRICT_ANSI__
  155. /*
  156. *Pipes
  157. */
  158. _CRTIMPFILE*__cdecl_popen(constchar*,constchar*);
  159. _CRTIMPint__cdecl_pclose(FILE*);
  160. #ifndefNO_OLDNAMES
  161. _CRTIMPFILE*__cdeclpopen(constchar*,constchar*);
  162. _CRTIMPint__cdeclpclose(FILE*);
  163. #endif
  164. /*
  165. *OtherNonANSIfunctions
  166. */
  167. _CRTIMPint__cdecl_flushall(void);
  168. _CRTIMPint__cdecl_fgetchar(void);
  169. _CRTIMPint__cdecl_fputchar(int);
  170. _CRTIMPFILE*__cdecl_fdopen(int,constchar*);
  171. _CRTIMPint__cdecl_fileno(FILE*);
  172. _CRTIMPint__cdecl_fcloseall(void);
  173. _CRTIMPFILE*__cdecl_fsopen(constchar*,constchar*,int);
  174. #ifdef__MSVCRT__
  175. _CRTIMPint__cdecl_getmaxstdio(void);
  176. _CRTIMPint__cdecl_setmaxstdio(int);
  177. #endif
  178. #ifndef_NO_OLDNAMES
  179. _CRTIMPint__cdeclfgetchar(void);
  180. _CRTIMPint__cdeclfputchar(int);
  181. _CRTIMPFILE*__cdeclfdopen(int,constchar*);
  182. _CRTIMPint__cdeclfileno(FILE*);
  183. #endif/*Not_NO_OLDNAMES*/
  184. #define_fileno(__F)((__F)->_file)
  185. #ifndef_NO_OLDNAMES
  186. #definefileno(__F)((__F)->_file)
  187. #endif
  188. #ifdefined(__MSVCRT__)&&!defined(__NO_MINGW_LFS)
  189. #include<sys/types.h>
  190. __CRT_INLINEFILE*__cdeclfopen64(constchar*filename,constchar*mode)
  191. {
  192. returnfopen(filename,mode);
  193. }
  194. int__cdeclfseeko64(FILE*,off64_t,int);
  195. #ifdef__USE_MINGW_FSEEK
  196. int__cdecl__mingw_fseeko64(FILE*,off64_t,int);
  197. #definefseeko64(fp,offset,whence)__mingw_fseeko64(fp,offset,whence)
  198. #endif
  199. __CRT_INLINEoff64_t__cdeclftello64(FILE*stream)
  200. {
  201. fpos_tpos;
  202. if(fgetpos(stream,&pos))
  203. return-1LL;
  204. else
  205. return((off64_t)pos);
  206. }
  207. #endif/*__NO_MINGW_LFS*/
  208. #endif/*Not__STRICT_ANSI__*/
  209. /*Wideversions*/
  210. #ifndef_WSTDIO_DEFINED
  211. /*alsoinwchar.h-keepinsync*/
  212. _CRTIMPint__cdeclfwprintf(FILE*,constwchar_t*,...);
  213. _CRTIMPint__cdeclwprintf(constwchar_t*,...);
  214. _CRTIMPint__cdeclswprintf(wchar_t*,constwchar_t*,...);
  215. _CRTIMPint__cdecl_snwprintf(wchar_t*,size_t,constwchar_t*,...);
  216. _CRTIMPint__cdeclvfwprintf(FILE*,constwchar_t*,__VALIST);
  217. _CRTIMPint__cdeclvwprintf(constwchar_t*,__VALIST);
  218. _CRTIMPint__cdeclvswprintf(wchar_t*,constwchar_t*,__VALIST);
  219. _CRTIMPint__cdecl_vsnwprintf(wchar_t*,size_t,constwchar_t*,__VALIST);
  220. _CRTIMPint__cdeclfwscanf(FILE*,constwchar_t*,...);
  221. _CRTIMPint__cdeclwscanf(constwchar_t*,...);
  222. _CRTIMPint__cdeclswscanf(constwchar_t*,constwchar_t*,...);
  223. _CRTIMPwint_t__cdeclfgetwc(FILE*);
  224. _CRTIMPwint_t__cdeclfputwc(wchar_t,FILE*);
  225. _CRTIMPwint_t__cdeclungetwc(wchar_t,FILE*);
  226. #ifdef__MSVCRT__
  227. _CRTIMPwchar_t*__cdeclfgetws(wchar_t*,int,FILE*);
  228. _CRTIMPint__cdeclfputws(constwchar_t*,FILE*);
  229. _CRTIMPwint_t__cdeclgetwc(FILE*);
  230. _CRTIMPwint_t__cdeclgetwchar(void);
  231. _CRTIMPwchar_t*__cdecl_getws(wchar_t*);
  232. _CRTIMPwint_t__cdeclputwc(wint_t,FILE*);
  233. _CRTIMPint__cdecl_putws(constwchar_t*);
  234. _CRTIMPwint_t__cdeclputwchar(wint_t);
  235. _CRTIMPFILE*__cdecl_wfdopen(int,wchar_t*);
  236. _CRTIMPFILE*__cdecl_wfopen(constwchar_t*,constwchar_t*);
  237. _CRTIMPFILE*__cdecl_wfreopen(constwchar_t*,constwchar_t*,FILE*);
  238. _CRTIMPFILE*__cdecl_wfsopen(constwchar_t*,constwchar_t*,int);
  239. _CRTIMPwchar_t*__cdecl_wtmpnam(wchar_t*);
  240. _CRTIMPwchar_t*__cdecl_wtempnam(constwchar_t*,constwchar_t*);
  241. _CRTIMPint__cdecl_wrename(constwchar_t*,constwchar_t*);
  242. _CRTIMPint__cdecl_wremove(constwchar_t*);
  243. _CRTIMPvoid__cdecl_wperror(constwchar_t*);
  244. _CRTIMPFILE*__cdecl_wpopen(constwchar_t*,constwchar_t*);
  245. #endif/*__MSVCRT__*/
  246. #ifndef__NO_ISOCEXT/*externsinlibmingwex.a*/
  247. int__cdeclsnwprintf(wchar_t*s,size_tn,constwchar_t*format,...);
  248. __CRT_INLINEint__cdecl
  249. vsnwprintf(wchar_t*s,size_tn,constwchar_t*format,__VALISTarg)
  250. {return_vsnwprintf(s,n,format,arg);}
  251. int__cdeclvwscanf(constwchar_t*__restrict__,__VALIST);
  252. int__cdeclvfwscanf(FILE*__restrict__,
  253. constwchar_t*__restrict__,__VALIST);
  254. int__cdeclvswscanf(constwchar_t*__restrict__,
  255. constwchar_t*__restrict__,__VALIST);
  256. #endif
  257. #define_WSTDIO_DEFINED
  258. #endif/*_WSTDIO_DEFINED*/
  259. #ifndef__STRICT_ANSI__
  260. #ifdef__MSVCRT__
  261. #ifndefNO_OLDNAMES
  262. _CRTIMPFILE*__cdeclwpopen(constwchar_t*,constwchar_t*);
  263. #endif/*notNO_OLDNAMES*/
  264. #endif/*MSVCRTruntime*/
  265. /*
  266. *OtherNonANSIwidefunctions
  267. */
  268. _CRTIMPwint_t__cdecl_fgetwchar(void);
  269. _CRTIMPwint_t__cdecl_fputwchar(wint_t);
  270. _CRTIMPint__cdecl_getw(FILE*);
  271. _CRTIMPint__cdecl_putw(int,FILE*);
  272. #ifndef_NO_OLDNAMES
  273. _CRTIMPwint_t__cdeclfgetwchar(void);
  274. _CRTIMPwint_t__cdeclfputwchar(wint_t);
  275. _CRTIMPint__cdeclgetw(FILE*);
  276. _CRTIMPint__cdeclputw(int,FILE*);
  277. #endif/*Not_NO_OLDNAMES*/
  278. #endif/*__STRICT_ANSI*/
  279. #ifdef__cplusplus
  280. }
  281. #endif
  282. #endif/*NotRC_INVOKED*/
  283. #endif/*_STDIO_H_*/
  284.  
  285. stdio.h所包含的函数:
  286.  
  287. 文件访问
  288. fopen
  289. freopen
  290. fflush
  291. fclose
  292. 二进制输入/输出
  293. fread
  294. fwrite
  295. 非格式化输入/输出
  296. fgetc/getc
  297. fputc/putc
  298. ungetc
  299. fgets
  300. fputs
  301. 格式化输入/输出
  302. scanf/fscanf/sscanf
  303. printf/fprintf/sprintf
  304. perror
  305. 文件定位
  306. ftell
  307. fseek
  308. fgetpos
  309. fsetpos
  310. rewind
  311. 错误处理
  312. feof
  313. ferror
  314. 文件操作
  315. remove
  316. rename
  317. tmpfile

C 标准库 - <stdio.h>的更多相关文章

  1. C 标准库 - <setjmp.h>

    C 标准库 - <setjmp.h> 简介 setjmp.h 头文件定义了宏 setjmp().函数 longjmp() 和变量类型 jmp_buf,该变量类型会绕过正常的函数调用和返回规 ...

  2. C 标准库 - ctype.h

    C 标准库 - ctype.h This header declares a set of functions to classify and transform individual charact ...

  3. C 标准库 - string.h

    C 标准库 - string.h This header file defines several functions to manipulate C strings and arrays. stri ...

  4. C 标准库 - <assert.h>

    C 标准库 - <assert.h> 简介 C 标准库的 assert.h头文件提供了一个名为 assert 的宏,它可用于验证程序做出的假设,并在假设为假时输出诊断消息. 已定义的宏 a ...

  5. C 标准库 - <stdarg.h>

    C 标准库 - <stdarg.h> 简介 stdarg.h 头文件定义了一个变量类型 va_list 和三个宏,这三个宏可用于在参数个数未知(即参数个数可变)时获取函数中的参数. 可变参 ...

  6. C 标准库 - <signal.h>

    C 标准库 - <signal.h> 简介 signal.h 头文件定义了一个变量类型 sig_atomic_t.两个函数调用和一些宏来处理程序执行期间报告的不同信号. 库变量 下面是头文 ...

  7. C 标准库 - <math.h>

    C 标准库 - <math.h> 简介 math.h 头文件定义了各种数学函数和一个宏.在这个库中所有可用的功能都带有一个 double 类型的参数,且都返回 double类型的结果. 库 ...

  8. C 标准库 - <locale.h>

    C 标准库 - <locale.h> 简介 locale.h 头文件定义了特定地域的设置,比如日期格式和货币符号.接下来我们将介绍一些宏,以及一个重要的结构 struct lconv 和两 ...

  9. C 标准库 - <limits.h>

    C 标准库 - <limits.h> 简介 limits.h 头文件决定了各种变量类型的各种属性.定义在该头文件中的宏限制了各种变量类型(比如 char.int 和 long)的值. 这些 ...

  10. C 标准库 - <float.h>

    C 标准库 - <float.h> 简介 C 标准库的 float.h 头文件包含了一组与浮点值相关的依赖于平台的常量.这些常量是由 ANSI C 提出的,这让程序更具有可移植性.在讲解这 ...

随机推荐

  1. MySQL数据类型和运算符

    mysql支持多种数据类型,主要有下面三种: 数值数据类型 日期/时间类型 字符串类型 整数类型 不同数据类型有不同的取值范围,可存储的值的范围越大,则所需的存储空间也越大. 整数类型主要有: tin ...

  2. 利用HttpClient写的一个简单页面获取

    之前就听说过利用网络爬虫来获取页面,感觉还挺有意思的,要是能进行一下偏好搜索岂不是可以满足一下窥探欲. 后来从一本书上看到用HttpClient来爬取页面,虽然也有源码,但是也没说用的HttpClie ...

  3. C语言 · 素数求和

    算法提高 素数求和   时间限制:1.0s   内存限制:256.0MB      问题描述 输入一个自然数n,求小于等于n的素数之和 样例输入 2 样例输出 2 数据规模和约定 测试样例保证 2 & ...

  4. Android ListView 长按列表弹出菜单

    Android ListView 长按列表弹出菜单 设置长按菜单 listView.setOnCreateContextMenuListener(new View.OnCreateContextMen ...

  5. lua 的io操作,非常详细

    Lua 标准库 - 输入输出处理(input and output facilities) I/O库提供两种不同的方式进行文件处理 1.io表调用方式:使用io表,io.open将返回指定文件的描述, ...

  6. mysql 存储过程 invoker invoker

    方法一:修改存储过程的definer update mysql.proc set definer='root@localhost' where db='db_name'; 方法二:修改sql secu ...

  7. ftp 长传报错553 可能是选的目录不对

    ftp> put /root/20180711tmp.txt /cc.txt local: /root/20180711tmp.txt remote: /cc.txt 200 PORT comm ...

  8. shell两个数字的运算,一共三个变量

    #!/bin/bash #两个数运算的简单脚本 + ,一共三个参数 echo $# #对获取的参数以此判断是否包含[a-zA-Z]的东西,如果包含就退出.因为数字相加不是数字就是加减乘除 for i_ ...

  9. Windows与Linux下进程间通信技术比较

    一般我们写的程序都是以单个进程的方式来运行的,比较少涉及到多进程.特别是在windows下,因为Windows是按照线程来分配CPU时间片的,线程是最小的调度单位,所以在Windows下更多的用到多线 ...

  10. C++ Primer学习笔记(三) C++中函数是一种类型!!!

    C++中函数是一种类型!C++中函数是一种类型!C++中函数是一种类型! 函数名就是变量!函数名就是变量!函数名就是变量! (---20160618最新消息,函数名不是变量名...囧) (---201 ...