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.

Prototype: size_t wcstombs(char *s, const wchar_t *wcs,<br />

size_t n);<br />

Arguments: s points to the multibyte string<br />

wcs points to the wide character string<br />

n the number of characters to convert<br />

Return Value: Returns the number of characters stored excluding the null<br />

character.<br />

Remarks: wcstombsconverts nnumber of multibyte characters unless it<br />

encounters a null character first. MPLAB C30 does not support<br />

multibyte characters with length greater than 1 character.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

Thư viện chuẩn C với hàm toán học<br />

2004 Microchip Technology Inc DS51456B trang 297<br />

memcpy<br />

Mô tả: Bản sao các ký tự từ một bộ đệm khác.<br />

Bao gồm:<br />

Nguyên mẫu: void * memcpy (void * dst, const void * src, size_t n);<br />

Đối số: đệm dst để sao chép nhân vật<br />

src đệm để sao chép các nhân vật từ<br />

số n ký tự sao chép<br />

Quay trở lại giá trị: Trả dst.<br />

Bình luận: memcpycopies ncharacters từ bộ đệm các nguồn srcto<br />

điểm đến dst đệm. Nếu bộ đệm chồng lên nhau, hành vi này là không xác định.<br />

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

DS51456B-page 294<br />

2004 Microchip Technology Inc.<br />

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

4.15 STRING FUNCTIONS<br />

The header file string.hconsists of types, macros and functions that provide tools<br />

to manipulate strings.<br />

size_t<br />

Description: The type of the result of the sizeofoperator.<br />

Include: <br />

NULL<br />

Description: The value of a null pointer constant.<br />

Include: <br />

memchr<br />

Description: Locates a character in a buffer.<br />

Include: <br />

Prototype: void *memchr(const void *s, int c, size_t n);<br />

Arguments: s pointer to the buffer<br />

c character to search for<br />

n number of characters to check<br />

Return Value: Returns a pointer to the location of the match if successful;<br />

otherwise,<br />

returns null.<br />

Remarks: memchrstops when it finds the first occurrence of cor after searching<br />

nnumber of characters.<br />

Example: #include /* for memchr, NULL */<br />

#include /* for printf */<br />

int main(void)<br />

{<br />

char buf1[50] = "What time is it?";<br />

int main (void)<br />

{<br />

char buf1 [50] = "";<br />

char buf2 [50] = "đâu là thời điểm";<br />

char buf3 [50] = "Tại sao?";<br />

printf ("buf1:% s \ n", buf1);<br />

printf ("buf2:% s \ n", buf2);<br />

printf ("buf3:% s \ n \ n", buf3);<br />

memcpy (buf1, buf2, 6);<br />

printf ("buf1 sau memcpy 6 ký tự của"<br />

"Buf2: \ n \ t% s \ n", buf1);<br />

printf ("\ n");<br />

memcpy (buf1, buf3, 5);<br />

printf ("buf1 sau memcpy 5 ký tự của"<br />

"Buf3: \ n \ t% s \ n", buf1);<br />

}<br />

Đầu ra:<br />

buf1:<br />

buf2: đâu là thời gian?<br />

buf3: Tại sao?<br />

buf1 sau memcpy of6 ký tự của buf2:<br />

Ở đâu<br />

buf1 sau memcpy of5 ký tự của buf3:<br />

Tại sao?<br />

dsPIC

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

Saved successfully!

Ooh no, something went wrong!