c语言实验报告《文件操作》,c语言文件操作总结.docx

C语言文件操作总结

File manipulation function

File on / off

FILE, *infile, =fopen ("ride? in〃,〃W〃);

Fclose (inf订e);

File read:

Fgetc:

Format: int fgetc (FILE ^stream);

Reads a character from the file pointing to the file pointer stream?

The return value of this function is a byte that returns the read. Returns EOF (-1) if it is read at the end of the file or when the error is read.

Fgets:

The prototype is char *f gets (char, *s, int, N, FILE, * stream);

Parameter:

*s: character pointer to the data address that will be stored.

N: integer data, which reads n - 1 characters from the stream.

^stream: pointer data, the stream to read.

Function:

Read nT characters from the file pointer stream, save in the space where s is the starting address, until you have completed a row, and if successful, return the pointer to s, or else return NULL.

Fscanf:

Function name: fscanf

Function: performs formatted input from a stream, fscanf ends with spaces and line breaks, and ends with spaces? This is different from fgets, where fgets encounters spaces that do not end.

Usage: int, fscanf (FILE, ^stream, char, ^format,

[argument ,???);

Int fscanf (file pointer, format string, input list);

Example:fscanf (FP,%s%d%lf, a, &b, &c)

Return value: integer, value equal to the number of [argument??? _

Fread:

Function prototypes: size_t, FREAD (void, ^buffer, size_t, size, size_t, count, FILE, ^stream);

Function: read data from a file stream, read count elements, each element size bytes? If the call succeeds, return count?? If the call is successful, the actual read size*count bytes are read

Parameter:

Buffer: is used to receive data memory addresses, at least size*count bytes in size

Size: the size of a single element, in bytes

The number of count: elements, each of which is size bytes? Stream: input stream

Return value: the number of elements actually read. If the return value is not the same as count (not count*size), the end or error of the file may occur

Gets the error information from f err or and f

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值