mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 06:55:36 +08:00
42 lines
1.1 KiB
HTML
42 lines
1.1 KiB
HTML
<h1>字符串函数 - memccpy</h1>
|
||
|
||
|
||
<p>原型:extern void *memccpy(void *dest, void *src, unsigned char ch, unsigned int count);</p>
|
||
|
||
<p>用法:#include <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 <syslib.h>
|
||
#include <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>
|
||
|