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.

Arguments: s string to be written<br />

stream pointer to the open stream<br />

Return Value: Returns a non-negative value if successful; otherwise, returns<br />

EOF.<br />

Remarks: The function writes characters tothe output stream up to but not<br />

including the null character.<br />

Example: #include /* for fputs, stdout */<br />

int main(void)<br />

{<br />

char buf[] = "This is text\n";<br />

fputs(buf,stdout);<br />

fputs("|",stdout);<br />

}<br />

Output:<br />

This is text<br />

|<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

fclosewas gọi. Sau đó, nó sẽ mở ra các tập tin mới như fopenwas<br />

gọi. freopenwill thất bại nếu dòng quy định không mở cửa. Xem fopen<br />

cho các loại có thể truy cập tập tin.<br />

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

/ * Printf, fclose, * /<br />

/ * FILE, NULL * /<br />

int main (void)<br />

{<br />

FILE * myfile1, * myfile2;<br />

int y;<br />

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

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

khác<br />

{<br />

printf ("afile1 được mở \ n");<br />

if ((myfile2 = freopen ("afile2", "w +",<br />

myfile1)) == NULL)<br />

{<br />

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

DS51456B-page 240<br />

fread<br />

2004 Microchip Technology Inc.<br />

fclose (myfile1);<br />

}<br />

Description: Reads data from the stream.<br />

Include: <br />

Prototype: size_t fread(void *ptr, size_t size, size_t nelem,<br />

FILE *stream);<br />

Arguments: ptr pointer to the storage buffer<br />

size size of item<br />

nelem maximum number of items to be read<br />

stream pointer to the stream<br />

Return Value: Returns the number of complete elements read up to nelemwhose<br />

size is specified by size.<br />

Remarks: The function reads characters froma given stream into the buffer<br />

pointed to by ptruntil the function stores size* nelemcharacters<br />

or sets the end-of-file or error indicator. freadreturns n/size where n is<br />

the number of characters it read. If n is not a multiple of size, the value<br />

of the last element is indeterminate. If the function sets the error<br />

indicator, the file-position indicator is indeterminate.<br />

Example: #include /* for fread, fwrite, */<br />

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

khác<br />

{<br />

printf ("afile2 được mở \ n");<br />

fclose (myfile2);<br />

}<br />

}<br />

}<br />

Đầu ra:<br />

afile1 đã được mở<br />

afile2 đã được mở<br />

Giải thích:<br />

Chương trình này sử dụng điểm myfile2to vào dòng khi freopenis<br />

gọi là như vậy nếu một lỗi xảy ra, vẫn myfile1will trỏ đến dòng và<br />

có thể được đóng đúng cách. Nếu freopencall thành công, myfile2can<br />

được sử dụng để đóng dòng đúng cách.<br />

fscanf<br />

Mô tả: Quét định dạng văn bản từ một dòng suối.<br />

Bao gồm:

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

Saved successfully!

Ooh no, something went wrong!