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.

ungetc (Continued)<br />

Standard C Libraries with Math Functions<br />

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

vfprintf<br />

Description: Prints formatted data to a stream using a variable length argument<br />

list.<br />

Include: <br />

<br />

Prototype: int vfprintf(FILE *stream, const char *format,<br />

va_list ap);<br />

Arguments: stream pointer to the open stream<br />

errmsg ("Bức thư '% c' không phải là% s \ n", 'a',<br />

"Một số nguyên.");<br />

errmsg ("Yêu cầu% d% s \ n", num,<br />

"Hoặc nhiều ký tự. \ N");<br />

}<br />

Đầu ra:<br />

Lỗi: chữ 'a' isnot một số nguyên.<br />

Lỗi: Yêu cầu 3 ormore ký tự.<br />

dsPIC<br />

®<br />

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

format format control string<br />

DS51456B trang 270<br />

2004 Microchip Technology Inc<br />

ap pointer to a list of arguments<br />

Return Value: Returns number of characters generated or a negative number if<br />

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 vfprintf<br />

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

details see stdarg.h.<br />

Example: #include /* forvfprintf, fopen, */<br />

/* fclose, printf, */<br />

/* FILE, NULL */<br />

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

/* va_list, va_end */<br />

FILE *myfile;<br />

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

{<br />

va_list ap;<br />

va_start(ap, fmt);<br />

vfprintf(myfile, fmt, ap);<br />

va_end(ap);<br />

}<br />

int main(void)<br />

{<br />

int num = 3;<br />

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

4.14 CHỨC NĂNG TIỆN ÍCH<br />

Các stdlib.hconsists tập tin tiêu đề của các loại, macro và các chức năng cung<br />

cấp các văn bản<br />

chuyển đổi, quản lý bộ nhớ, tìm kiếm và phân loại khả năng, và các chung<br />

tiện ích.<br />

div_t<br />

Mô tả: Một loại chứa một thương và phần còn lại của một bộ phận nguyên ký<br />

với toán hạng kiểu int.<br />

Bao gồm:<br />

Nguyên mẫu: struct {intquot, rem; } Div_t;<br />

Ghi chú: Đây là loại cấu trúc hàm trả về div.<br />

ldiv_t<br />

Mô tả: Một loại chứa một thương và phần còn lại của một bộ phận nguyên ký<br />

với toán hạng của loại dài.<br />

Bao gồm:<br />

Nguyên mẫu: struct {quot dài, rem; } Ldiv_t;<br />

Ghi chú: Đây là loại cấu trúc hàm trả về ldiv.<br />

size_t<br />

Mô tả: Các loại kết quả của sizeofoperator.<br />

Bao gồm:<br />

wchar_t<br />

Mô tả: Một loại chứa một giá trị nhân vật rộng.<br />

Bao gồm:<br />

EXIT_FAILURE<br />

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

Bao gồm:<br />

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

chấm dứt tình trạng không thành công

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

Saved successfully!

Ooh no, something went wrong!