bcopy()函数
原型:void bcopy(const void *src, void *dest, int n)
用法:#include <string.h>
功能:将字符串src的前n个字节复制到dest中。
说明:bcopy()函数与memcpy()函数一样都是用来拷贝src所指的内存内容前n个字节到dest所指的地址,不过参数src与dest在传给
函数时,是相反的位置;bcopy()函数不检查字符串中的空字节NULL,并且函数没有返回值,所以建议使用memcpy()函数代替。
举例:
#include <string.h>
#include <stdio.h>
main()
{
char dest[30]="string(a)";
char src[30]="string_1 string_2";
int i;
bcopy(src,dest,30); /* src指针放在前*/
printf("bcopy():%s\n",dest);
for(i=0;i<30;i++)
printf("%c",dest[i]);
memcpy(dest,src,30); /*dest指针放在前*/
printf("\nmemcpy():%s\n",dest);
for(i=0;i<30;i++)
printf("%c",dest[i]);
printf("\n");
return 0;
}