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.

Include: <br />

Prototype: char *tmpnam(char *s);<br />

Argument: s pointer to the temporary name<br />

Return Value: Returns a pointer to the filename generated and stores the<br />

filename in<br />

s. If it can not generate a filename, the NULL pointer is returned.<br />

Remarks: The created filename will not conflict with an existing file name. Use<br />

Đầu ra:<br />

Nội dung afile.txt<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 />

L_tmpnamto define the size of array the argument of tmpnampoints<br />

to.<br />

DS51456B trang 268<br />

vprintf<br />

2004 Microchip Technology Inc<br />

Example: #include /* for tmpnam, L_tmpnam, */<br />

/* printf, NULL */<br />

int main(void)<br />

{<br />

char *myfilename;<br />

char mybuf[L_tmpnam];<br />

char *myptr = (char *) &mybuf;<br />

if ((myfilename = tmpnam(myptr)) == NULL)<br />

printf("Cannot create temporary file name");<br />

else<br />

printf("Temporary file %s was created",<br />

myfilename);<br />

}<br />

Output:<br />

Temporary file ctm00001.tmp was created<br />

ungetc<br />

Description: Pushes character back onto stream.<br />

Include: <br />

Prototype: int ungetc(int c, FILE *stream);<br />

Argument: c character to be pushed back<br />

stream pointer to the open stream<br />

Return Value: Returns the pushed character if successful; otherwise, returns<br />

EOF<br />

Remarks: The pushed back character will be returned by a subsequent read on<br />

the stream. If more than one character is pushed back, they will be<br />

returned in the reverse order of their pushing. A successful call to a file<br />

positioning function (fseek, fsetposor rewind) cancels any pushed<br />

back characters. Only one character of pushback is guaranteed.<br />

Multiple calls to ungetcwithout an intervening read or file positioning<br />

operation may cause a failure.<br />

dsPIC<br />

Mô tả: In định dạng văn bản để stdoutusing một danh sách đối số chiều dài biến<br />

Bao gồm:<br />

Nguyên mẫu: int vprintf (const char * format, va_list ap);<br />

Đối số: chuỗi định dạng kiểm soát định dạng<br />

ap con trỏ đến một danh sách các đối số trở lại giá trị: Trả về số ký tự được tạo<br />

ra hoặc một số âm nếu một<br />

lỗi xảy ra.<br />

Ghi chú: Đối số định dạng có cú pháp tương tự và sử dụng nó có trong<br />

printf.<br />

Để truy cập vào danh sách đối số chiều dài biến, apvariable phải<br />

khởi tạo bởi các va_startand vĩ mô có thể được khởi tạo lại bởi<br />

cuộc gọi bổ sung cho va_arg. Điều này phải được thực hiện trước khi vprintf<br />

hàm được gọi. Gọi va_endafter trở về chức năng. Để biết thêm<br />

chi tiết xem stdarg.h<br />

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

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

/ * Va_list, va_end * /<br />

khoảng trống errmsg (const char * fmt, ...)<br />

{<br />

va_list ap;<br />

va_start (ap, fmt);<br />

printf ("Lỗi:");<br />

vprintf (fmt, ap);<br />

va_end (ap);<br />

}<br />

int main (void)<br />

{<br />

int num = 3;<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,

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

Saved successfully!

Ooh no, something went wrong!