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.

printf("\"%s\" found at position %d\n",<br />

str2, res);<br />

}<br />

else<br />

printf("\"%s\" not found\n", str2);<br />

strspn (Continued)<br />

Standard C Libraries with Math Functions<br />

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

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

ptr = strstr(str1, str3);<br />

if (ptr != NULL)<br />

{<br />

res = ptr - str1 + 1;<br />

printf("\"%s\" found at position %d\n",<br />

str3, res);<br />

}<br />

else<br />

printf("\"%s\" not found\n", str3);<br />

}<br />

Output:<br />

str1 : What time is it?<br />

str2 : is<br />

str3 : xyz<br />

"is" found at position 11<br />

"xyz" not found<br />

strtok<br />

Description: Break a string into substrings, or tokens, by inserting null<br />

characters in<br />

place of specified delimiters.<br />

Include: <br />

Prototype: char *strtok(char *s1, const char *s2);<br />

Arguments: s1 pointer to the null terminated string to be searched<br />

s2 pointer to characters to be searched for (used as delimiters)<br />

Return Value: Returns a pointer to the first character of a token (the first<br />

character in<br />

s1that does not appear in the set of characters of s2). If no token is<br />

found, the null pointer is returned.<br />

Remarks: A sequence of calls to this function can be used to split up a string<br />

into<br />

substrings (or tokens) by replacing specified characters with null<br />

thời gian thực tế.<br />

dsPIC<br />

®<br />

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

DS51456B trang 318 2004 Microchip Technology Inc<br />

NULL<br />

Mô tả: Giá trị của một con trỏ hằng null.<br />

Bao gồm:<br />

asctime<br />

Mô tả: Chuyển đổi cơ cấu thời gian để một chuỗi ký tự.<br />

Bao gồm:<br />

Prototype: char * asctime (const struct tm * tptr);<br />

Đối số: tptr lần / ngày cấu trúc<br />

Quay trở lại giá trị: Trả về một con trỏ đến một chuỗi ký tự định dạng sau:<br />

DDD MMM dd hh: mm: ss YYYY<br />

DDDis ngày trong tuần<br />

MMMis tháng trong năm<br />

ddis ngày của tháng<br />

hhis giờ<br />

phút mmis<br />

SSIS thứ hai<br />

YYYYis năm<br />

Ví dụ: # include / * Cho asctime, tm * /<br />

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

dễ bay hơi int i;<br />

int main (void)<br />

{<br />

struct tm khi;<br />

whattime time_t;<br />

when.tm_sec = 30;<br />

when.tm_min = 30;<br />

when.tm_hour = 2;<br />

when.tm_mday = 1;<br />

when.tm_mon = 1;<br />

when.tm_year = 103;<br />

whattime = mktime (và khi nào);<br />

printf ("Ngày và thời gian là% s \ n", asctime (và khi nào));<br />

}<br />

Đầu ra:

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

Saved successfully!

Ooh no, something went wrong!