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.

printf("Cannot open afile.txt\n");<br />

else<br />

{<br />

errmsg("Error: The letter '%c' is not %s\n", 'a',<br />

"an integer value.");<br />

errmsg("Error: Requires %d%s%c", num,<br />

" or more characters.", '\n');<br />

}<br />

fclose(myfile);<br />

}<br />

Output:<br />

Contents of afile.txt<br />

Error: The letter 'a' isnot an integer value.<br />

Error: Requires 3 ormore characters.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

Ví dụ: Xem exitfor ví dụ về sử dụng.<br />

EXIT_SUCCESS<br />

Mô tả: Báo cáo kết thúc thành công<br />

Bao gồm:<br />

Bình luận: EXIT_SUCCESSis một giá trị cho các chức năng thoát để trở về mộ<br />

thành công<br />

trạng thái chấm dứt.<br />

Ví dụ: Xem exitfor ví dụ về sử dụng.<br />

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

2004 Microchip Technology Inc DS51456B trang 271<br />

MB_CUR_MAX<br />

Mô tả: Tối đa số charactersin một nhân vật nhiều byte<br />

Bao gồm:<br />

Giá trị: 1<br />

NULL<br />

Mô tả: Giá trị của một con trỏ hằng rỗng<br />

Bao gồm:<br />

RAND_MAX<br />

DS51456B-page 268<br />

vprintf<br />

2004 Microchip Technology Inc.<br />

Mô tả: Giá trị tối đa khả năng được trả về bởi randfunction<br />

Bao gồm:<br />

Description: Prints formatted text to stdoutusing a variable length argument list<br />

Include: <br />

<br />

Prototype: int vprintf(const char *format, va_list ap);<br />

Arguments: format format control string<br />

ap pointer to a list of arguments Return Value: Returns number of characters<br />

generated or a negative number if an<br />

error occurs.<br />

Remarks: The format argument has the same syntax and use that it has in<br />

printf.<br />

To access the variable length argument list, the apvariable must be<br />

initialized by the macro va_startand may be reinitialized by<br />

additional calls to va_arg. This must be done before the vprintf<br />

function is called. Invoke va_endafter the function returns. For more<br />

details see stdarg.h<br />

Example: #include /* for vprintf, printf */<br />

#include /* for va_start, */<br />

/* va_list, va_end */<br />

void errmsg(const char *fmt, ...)<br />

{<br />

Giá trị: 32767<br />

hủy bỏ<br />

Mô tả: hủy bỏ quá trình hiện tại.<br />

Bao gồm:<br />

Prototype: void abort (void);<br />

Bình luận: abortwill gây ra bộ vi xử lý để thiết lập lại.<br />

Ví dụ: # include / * Cho fopen, fclose, * /<br />

/ * Printf, FILE, NULL * /<br />

# include / * Cho hủy bỏ * /<br />

int main (void)<br />

{<br />

FILE * myfile;<br />

if ((myfile = fopen ("samp.fil", "r")) == NULL)<br />

{<br />

printf ("Không thể mở samp.fil \ n");<br />

hủy bỏ ();<br />

}<br />

khác<br />

printf ("Thành công mở samp.fil \ n");<br />

fclose (myfile);

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

Saved successfully!

Ooh no, something went wrong!