30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

to perform input and output operations on files and streams. When a file is<br />

opened it is<br />

associated with a stream. A stream is a pipeline for the flow of data into and out<br />

of files.<br />

Because different systems use different properties, the stream provides more<br />

uniform<br />

properties to allow reading and writing of the files.<br />

Streams can be text streams or binary streams. Text streams consist of a<br />

sequence of<br />

characters divided into lines. Each line is terminated with a newline ('\n')<br />

character.<br />

The characters may be altered in their internalrepresentation, particularly in<br />

regards to<br />

line endings. Binary streams consist of sequences of bytes of information. The<br />

bytes<br />

transmitted to the binary stream are not altered.There is no concept of lines, the<br />

file is<br />

just a series of bytes.<br />

At startup three streams are automatically opened: stdin, stdout, and stderr.<br />

stdinprovides a stream for standard input, stdoutis standard output and stderr<br />

is the standard error. Additional streams may be created with the fopenfunction.<br />

See<br />

fopenfor the different types of file access that are permitted. These access types<br />

are<br />

used by fopenand freopen.<br />

The type FILEis used to store information about each opened file stream. It<br />

includes<br />

such things as error indicators, end of file indicators, file position indicators, and<br />

other<br />

internal status information needed to control a stream. Many functions in the<br />

stdio<br />

use FILEas an argument.<br />

There are three types of buffering: unbuffered, line buffered and fully buffered.<br />

Unbuffered means a character or byte is transferred one at a time. Line buffered<br />

collects and<br />

transfers an entire line at a time (i.e., the newline character indicates the end of a<br />

line.)<br />

Fully buffered allows blocks of an arbitrary size to be transmitted. The functions<br />

setbufand setvbufcontrol file buffering.<br />

The stdio.hfile also contains functions that use input and output formats. The<br />

input<br />

formats, or scan formats, are used for reading data. Their descriptions can be<br />

found<br />

under scanf, but they are also used by fscanfand sscanf. The output formats, or<br />

print formats, are used for writing data. Their descriptions can be found under<br />

printf.<br />

These print formats are also used by fprintf, sprintf, vfprintf, vprintfand<br />

con trỏ<br />

Bao gồm:<br />

Ví dụ: Xem ví dụ cho fseek.<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 228 2004 Microchip Technology Inc<br />

SEEK_END<br />

Mô tả: Chỉ ra rằng fseekshould tìm kiếm từ khi kết thúc tập tin.<br />

Bao gồm:<br />

Ví dụ: Xem ví dụ cho fseek.<br />

SEEK_SET<br />

Mô tả: Chỉ ra rằng fseekshould tìm kiếm từ đầu của tập tin.<br />

Bao gồm:<br />

Ví dụ: Xem ví dụ cho fseek.<br />

stderr<br />

Mô tả: File con trỏ đến dòng lỗi chuẩn.<br />

Bao gồm:<br />

stdin<br />

Mô tả: File con trỏ đến dòng đầu vào tiêu chuẩn.<br />

Bao gồm:<br />

thiết bị xuất chuẩn<br />

Mô tả: File con trỏ đến dòng đầu ra tiêu chuẩn.<br />

Bao gồm:<br />

TMP_MAX<br />

Mô tả: Số lượng tối đa của tên tập tin duy nhất chức năng tmpnamcan<br />

tạo ra.<br />

Bao gồm:<br />

Giá trị: 32<br />

Thư viện chuẩn C với hàm toán học<br />

2004 Microchip Technology Inc DS51456B trang 229<br />

clearerr<br />

Mô tả: Cấu hình lại các indictor lỗi cho các dòng<br />

Bao gồm:<br />

Prototype: void clearerr (FILE * stream);<br />

Đối số: streamstream để thiết lập lại các chỉ số lỗi<br />

Ghi chú: Các chức năng xóa các chỉ số cuối cùng của tập tin và báo lỗi cho cho<br />

dòng (ví dụ, feofand ferrorwill return false sau khi chức năng<br />

clearerris gọi.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!