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.

va_list ap;<br />

va_start(ap, fmt);<br />

printf("Error: ");<br />

vprintf(fmt, ap);<br />

va_end(ap);<br />

}<br />

int main(void)<br />

{<br />

int num = 3;<br />

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

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

errmsg("Requires %d%s\n", num,<br />

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

}<br />

Output:<br />

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

Error: Requires 3 ormore characters.<br />

Standard C Libraries with Math Functions<br />

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

vsprintf<br />

Description: Prints formatted text to a string using a variable length argument<br />

list<br />

Include: <br />

<br />

Prototype: int vsprintf(char *s, const char *format, va_list<br />

ap);<br />

Arguments: s storage string for output<br />

format format control string<br />

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

stored in sexcluding the terminating null<br />

character.<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 vsprintf<br />

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

details see stdarg.h<br />

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

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

}<br />

Đầu ra:<br />

Không thể mở samp.fil<br />

ABRT<br />

dsPIC<br />

®<br />

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

DS51456B trang 272 2004 Microchip Technology Inc<br />

abs<br />

Mô tả: Tính giá trị tuyệt đối.<br />

Bao gồm:<br />

Nguyên mẫu: int abs (int i);<br />

Đối số: i số nguyên giá trị<br />

Quay trở lại giá trị: Trả về giá trị tuyệt đối của tôi.<br />

Bình luận: Một số âm được trả về là tích cực; một số dương là<br />

không thay đổi.<br />

Ví dụ: # include / * Cho printf * /<br />

# include / * Cho abs * /<br />

int main (void)<br />

{<br />

int i;<br />

i = 12;<br />

printf ("Giá trị tuyệt đối của% d% d \ n",<br />

i, abs (i));<br />

i = -2;<br />

printf ("Giá trị tuyệt đối của% d% d \ n",<br />

i, abs (i));<br />

i = 0;<br />

printf ("Giá trị tuyệt đối của% d% d \ n",<br />

i, abs (i));<br />

}<br />

Đầu ra:<br />

Giá trị tuyệt đối của 12 là 12<br />

Giá trị tuyệt đối của -2 là 2<br />

Giá trị tuyệt đối của 0 là 0<br />

atexit<br />

Mô tả: Thanh ghi chức năng xác định được gọi khi chương trình<br />

chấm dứt bình thường.<br />

Bao gồm:

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

Saved successfully!

Ooh no, something went wrong!