30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NULL<br />

Description: The value of a null pointer constant<br />

Include: <br />

SEEK_CUR<br />

Description: Indicates that fseekshould seek from the current position of the file<br />

pointer<br />

Include: <br />

Example: See example for fseek.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 228<br />

SEEK_END<br />

2004 Microchip Technology Inc.<br />

Description: Indicates that fseekshould seek from the end of the file.<br />

Include: <br />

Example: See example for fseek.<br />

SEEK_SET<br />

Description: Indicates that fseekshould seek from the beginning of the file.<br />

Include: <br />

Example: See example for fseek.<br />

stderr<br />

Description: File pointer to the standard error stream.<br />

Include: <br />

stdin<br />

Description: File pointer to the standard input stream.<br />

Include: <br />

stdout<br />

Description: File pointer to the standard output stream.<br />

Include: <br />

TMP_MAX<br />

Description: The maximum number of unique filenames the function<br />

tmpnamcan<br />

generate.<br />

Include: <br />

Value: 32<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 229<br />

clearerr<br />

Description: Resets the error indictor for the stream<br />

/ * Fopen, fclose, FILE, * /<br />

/ * NULL * /<br />

int main (void)<br />

{<br />

FILE * myfile;<br />

int y = 0;<br />

if ((myfile = fopen ("afile.txt", "rb")) == NULL)<br />

printf ("Không thể mở tập tin \ n");<br />

khác<br />

{<br />

cho (;;)<br />

{<br />

y = fgetc (myfile);<br />

if (feof (myfile))<br />

phá vỡ;<br />

fputc (y, thiết bị xuất chuẩn);<br />

}<br />

fclose (myfile);<br />

}<br />

}<br />

Đầu vào:<br />

Nội dung afile.txt (được sử dụng như đầu vào):<br />

Đây là một câu.<br />

Đầu ra:<br />

Đây là một câu.<br />

dsPIC<br />

®<br />

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

DS51456B trang 232<br />

ferror<br />

2004 Microchip Technology Inc<br />

Mô tả: Kiểm tra xem chỉ số lỗi được thiết lập.<br />

Bao gồm:<br />

Nguyên mẫu: int ferror (FILE * stream);<br />

Đối số: dòng con trỏ đến FILEstructure<br />

Quay trở lại giá trị: Trả về một giá trị khác không hàm IFERROR chỉ số được<br />

thiết lập; nếu không, trả về một<br />

không.<br />

Ví dụ: / * Chương trình này sẽ cố gắng để viết một tập tin đó là * /<br />

/ * Chỉ đọc. Điều này làm cho chỉ số lỗi để * /<br />

/ * Được thiết lập. Các functionferror được sử dụng để kiểm tra * /

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

Saved successfully!

Ooh no, something went wrong!