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.

greater<br />

than 1 byte.<br />

mbstowcs<br />

Description: Converts a multibyte string to a wide character string. (See<br />

Remarks.)<br />

Include: <br />

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

size_t n);<br />

Arguments: wcs points to the wide character string<br />

s points to the multibyte string<br />

n the number of wide characters to convert.<br />

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

character.<br />

Remarks: mbstowcsconverts nnumber of wide characters unless it encounters<br />

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

characters with length greater than 1 byte.<br />

mbtowc<br />

Description: Converts a multibyte character to a wide character. (See Remarks.)<br />

Include: <br />

Prototype: int mbtowc(wchar_t *pwc, const char *s, size_t n);<br />

Arguments: pwc points to the wide character<br />

s points to the multibyte character<br />

n number of bytes to check<br />

Return Value: Returns zero if spoints to a null character; otherwise, returns 1<br />

Remarks: The resulting wide character will be stored at pwc. MPLAB C30 does<br />

not support multibyte characters with length greater than 1 byte.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 286<br />

qsort<br />

Description: Performs a quick sort.<br />

Include: <br />

2004 Microchip Technology Inc.<br />

Prototype: void qsort(void *base, size_t nelem, size_t size,<br />

int (*cmp)(const void *e1, const void *e2));<br />

Arguments: base pointer to the start of the array<br />

nelem number of elements<br />

size size of the elements<br />

cmp pointer to the comparison function<br />

e1 pointer to the key for the search e2 pointer to the element being compared<br />

== NULL)<br />

printf ("Không thể cấp phát bộ nhớ \ n");<br />

khác<br />

{<br />

printf ("bộ nhớ phân bổ \ n");<br />

/ * Nhiệt độ con trỏ trong trường hợp realloc () không thành công * /<br />

j = i;<br />

if ((i = (long *) realloc (i, 25 * sizeof (long)))<br />

== NULL)<br />

{<br />

printf ("Không thể tái phân bổ bộ nhớ \ n");<br />

/ * J chỉ để cấp phát bộ nhớ * /<br />

miễn phí (j);<br />

}<br />

khác<br />

{<br />

printf ("bộ nhớ phân bổ lại \ n");<br />

miễn phí (i);<br />

}<br />

}<br />

}<br />

Đầu ra:<br />

Cấp phát bộ nhớ<br />

Bộ nhớ phân bổ lại<br />

realloc (Tiếp theo)<br />

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

2004 Microchip Technology Inc DS51456B trang 289<br />

srand<br />

Mô tả: Đặt hạt giống khởi đầu cho chuỗi số giả ngẫu nhiên.<br />

Bao gồm:<br />

Prototype: void srand (unsigned int hạt giống);<br />

Giá trị bắt đầu hạt giống cho dãy số giả ngẫu nhiên: Đối số<br />

Trở lại giá trị: Không<br />

Bình luận: Chức năng này đặt hạt giống khởi đầu cho các số giả ngẫu nhiên<br />

tự tạo ra bởi các randfunction. Các randfunction sẽ<br />

luôn luôn trở về cùng một chuỗi các số nguyên hạt giống khi giống hệt nhau<br />

giá trị được sử dụng. Nếu randis gọi với một giá trị hạt giống số 1, trình tự<br />

số được tạo ra sẽ được giống như nếu randhad được gọi là<br />

mà không srandhaving được gọi là đầu tiên.

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

Saved successfully!

Ooh no, something went wrong!