C语言stdio库(#include<stdio.h>)

stdio.h头定义了三个变量的类型,几个宏及各种功能进行输入和输出。

库变量

以下是在头stdio.h中定义的变量类型:

S.N.

变量和说明

1

size_t 
这是一个无符号整数类型 sizeof关键字的结果。

2

FILE 
这是一个对象的类型,适合用于存储信息的一个文件流。

3

fpos_t 
这是一个对象类型适用于存储在一个文件中的任何位置。

库宏

以下是在头stdio.h中定义的宏:

S.N.

宏与说明

1

NULL
这个宏是一个空指针常量的值。

2

_IOFBF, _IOLBF and _IONBF 
这些都是宏扩大整型常量表达式具有鲜明的值和适合使用setvbuf函数的第三个参数。

3

BUFSIZ
这个宏是一个整数,它表示函数setbuf函数所使用的缓冲区的大小。

4

EOFM 
此宏是一个负整数,表示一个结束-已到达文件结尾。

5

FOPEN_MAX 
此宏是一个整数,代表文件的最大数目,该系统可以保证,可以同时打开。

6

FILENAME_MAX 
这个宏是一个整数,表示一个字符数组,适合持有时间最长的可能的文件名长度最长。如果实现没有任何限制,那么这个值应该是推荐的最大值。

7

L_tmpnam 
这个宏是一个整数,表示适合举行由tmpnam函数创建的临时文件名可能的最长的一个char数组的长度最长。

8

SEEK_CUR, SEEK_END, and SEEK_SET 
这些宏用于的fseek 函数定位在一个文件中的不同位置。

9

TMP_MAX 
这个宏是唯一的文件名的功能使用tmpnam可以生成的最大数量。

10

stderr, stdin, and stdout 
这些宏的文件类型对应的标准误差,标准输入,标准输出流的指针。

库函数

以下是在头stdio.h中定义的函数:

S.N.

函数及说明

1

void clearerr(FILE *stream)
Clears the end-of-file and error indicators for the given stream.

2

int fclose(FILE *stream)
Closes the stream. All buffers are flushed.

3

int feof(FILE *stream)
Tests the end-of-file indicator for the given stream.

4

int ferror(FILE *stream)
Tests the error indicator for the given stream.

5

int fflush(FILE *stream)
Flushes the output buffer of a stream.

6

int fgetpos(FILE *stream, fpos_t *pos)
Gets the current file position of the stream and writes it to pos.

7

FILE *fopen(const char *filename, const char *mode)
Opens the filename yiibaied to by filename using the given mode.

8

size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Reads data from the given stream into the array yiibaied to by ptr.

9

FILE *freopen(const char *filename, const char *mode, FILE *stream)
Associates a new filename with the given open stream and same time closing the old file in stream.

10

int fseek(FILE *stream, long int offset, int whence)
Sets the file position of the stream to the given offset. The argument offset signifies the number of bytes to seek from the given whence position.

11

int fsetpos(FILE *stream, const fpos_t *pos)
设置到给定位置的给定的流文件中的位置。参数pos 是由函数的fgetpos给定的位置。

12

long int ftell(FILE *stream)
返回给定流的当前文件位置。

13

size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
Writes data from the array yiibaied to by ptr to the given stream.

14

int remove(const char *filename)
Deletes the given filename so that it is no longer accessible.

15

int rename(const char *old_filename, const char *new_filename)
Causes the filename referred to by old_filename to be changed to new_filename.

16

void rewind(FILE *stream)
Sets the file position to the beginning of the file of the given stream.

17

void setbuf(FILE *stream, char *buffer)
Defines how a stream should be buffered.

18

int setvbuf(FILE *stream, char *buffer, int mode, size_t size)
Another function to define how a stream should be buffered.

19

FILE *tmpfile(void)
Creates a temporary file in binary update mode (wb+).

20

char *tmpnam(char *str)
Generates and returns a valid temporary filename which does not exist.

21

int fprintf(FILE *stream, const char *format, ...)
Sends formatted output to a stream.

22

int printf(const char *format, ...)
Sends formatted output to stdout.

23

int sprintf(char *str, const char *format, ...)
Sends formatted output to a string.

24

int vfprintf(FILE *stream, const char *format, va_list arg)
Sends formatted output to a stream using an argument list.

25

int vprintf(const char *format, va_list arg)
Sends formatted output to stdout using an argument list.

26

int vsprintf(char *str, const char *format, va_list arg)
Sends formatted output to a string using an argument list.

27

int fscanf(FILE *stream, const char *format, ...)
Reads formatted input from a stream.

28

int scanf(const char *format, ...)
Reads formatted input from stdin.

29

int sscanf(const char *str, const char *format, ...)
Reads formatted input from a string.

30

int fgetc(FILE *stream)
Gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream.

31

char *fgets(char *str, int n, FILE *stream)
Reads a line from the specified stream and stores it into the string yiibaied to by str. It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is reached, whichever comes first.

32

int fputc(int char, FILE *stream)
Writes a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream.

33

int fputs(const char *str, FILE *stream)
Writes a string to the specified stream up to but not including the null character.

34

int getc(FILE *stream)
获取下一个字符(unsigned char类型)从指定的流,并将流的指针位置。

35

int getchar(void)
从标准输入获取一个字符(unsigned char类型)。

36

char *gets(char *str)
从标准输入读取一行,并将其存储到由str指向的字符串。它时停止读取换行符或文件结束时达成,以先到为准。

37

int putc(int char, FILE *stream)
写入字符到指定的流,并将流的指针位置的参数指定一个字符(unsigned char类型)。

38

int putchar(int char)
写一个字符(unsigned char类型)的参数指定的字符输出到stdout

39

int puts(const char *str)
将一个字符串写入到stdout,但不包括空字符。一个换行符被追加到输出。

40

int ungetc(int char, FILE *stream)
将字符的字符(unsigned char类型)到指定的流,这是读取的下一字符。

41

void perror(const char *str)
打印一个描述性的错误消息到stderr。首先打印字符串str接着一个冒号,然后是一个空格。

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值