uTools-Manuals/docs/c/memccpy.html
2019-04-21 11:50:48 +08:00

42 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>字符串函数 - memccpy</h1>
<p>原型extern void *memccpy(void *dest, void *src, unsigned char ch, unsigned int count);</p>
<p>用法:#include &lt;string.h></p>
<p>功能由src所指内存区域复制不多于count个字节到dest所指内存区域如果遇到字符ch则停止复制。</p>
<p>说明返回指向字符ch后的第一个字符的指针如果src前n个字节中不存在ch则返回NULL。ch被复制。</p>
举例:<pre><code class="language-c">
// memccpy.c
#include &lt;syslib.h>
#include &lt;string.h>
main()
{
char *s="Golden Global View";
char d[20],*p;
clrscr();
p=memccpy(d,s,'x',strlen(s));
if(p)
{
*p='\0'; // MUST Do This
printf("Char found: %s.\n",d);
}
else
printf("Char not found.\n");
getchar();
return 0;
}
</code></pre>相关函数:<a href="memcpy.html">memcpy</a>,<a href="strcpy.html">strcpy</a>