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.

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

scanf<br />

Description: Scans formatted text from stdin.<br />

Include: <br />

Prototype: int scanf(const char *format, ...);<br />

Argument: format format control string<br />

... optional arguments<br />

Return Value: Returns the number of items successfully converted and assigned.<br />

If<br />

no items are assigned, a 0 is returned. EOF is returned if an input<br />

failure is encountered before the first.<br />

Remarks: Each format specifier begins with a percent sign followed by optional<br />

fields and a required type as shown here:<br />

%[*][width][modifier]type<br />

*<br />

indicates assignment suppression. This will cause the input field to<br />

be skipped and no assignment made.<br />

width<br />

specify the maximum number of input characters to match for the<br />

conversion not including white space that can be skipped.<br />

modifier<br />

h modifier - used with type d, i, o,u, x, X; converts the value to a<br />

short intor unsigned short int.<br />

h modifier - used with n; specifies that the pointer points to a<br />

short int<br />

l modifier - used with type d, i, o,u, x, X; converts the value to a<br />

long intor unsigned long int<br />

l modifier - used with n; specifies that the pointer points to a<br />

long int<br />

l modifier - used with c; specifies a wide character<br />

l modifier - used with type e, E, f, F, g, G; converts the value to a<br />

double<br />

ll modifier - used with type d, i, o, u, x, X; converts the value to a<br />

long long intor unsigned long long int<br />

ll modifier - used with n; specifies that the pointer points to a<br />

long long int<br />

L modifier - used with e, E, f, g, G; converts the value to a long<br />

double<br />

dsPIC<br />

}<br />

}<br />

Đầu ra:<br />

myfile1 không có đệm<br />

myfile2 có đầy đủ đệm<br />

dsPIC<br />

®<br />

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

DS51456B trang 262<br />

setvbuf<br />

2004 Microchip Technology Inc<br />

Mô tả: Xác định dòng để được đệm và kích thước bộ đệm.<br />

Bao gồm:<br />

Nguyên mẫu: int setvbuf (FILE * stream, char * buf, int mode,<br />

size_t size);<br />

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

buf sử dụng cấp phát bộ đệm<br />

loại chế độ đệm<br />

kích thước kích thước của bộ đệm<br />

Quay trở lại giá trị: Trả về 0 nếu thành công<br />

Bình luận: setvbufmust được gọi sau khi fopenbut trước khi bất kỳ chức năng<br />

khác<br />

các cuộc gọi hoạt động trên dòng suối. Đối với chế độ sử dụng một trong các<br />

cách sau:<br />

_IOFBF- Đủ đệm<br />

_IOLBF- Cho dòng đệm<br />

_IONBF- Không có đệm<br />

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

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

/ * _IONBF, _IOFBF * /<br />

int main (void)<br />

{<br />

FILE * myfile1, * myfile2;<br />

char buf [256];<br />

if ((myfile1 = fopen ("afile1", "w +")) = NULL)<br />

{<br />

if (setvbuf (myfile1, NULL, _IONBF, 0) == 0)<br />

printf ("myfile1 không có đệm \ n");<br />

khác<br />

printf ("Không thể xác định dòng đệm"<br />

"Và / hoặc kích thước \ n");

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

Saved successfully!

Ooh no, something went wrong!