1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > c语言实验报告《文件操作》 c语言文件操作总结.docx

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

时间:2020-12-28 19:59:56

相关推荐

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。