1.数据类型认识
“unsigned int”
32位系统下,int 2 char 1, double 8 long 4 字节数
2.strcpy和memcpy到底有什么不同
strcpy自动检查字符串结束,就是/0结束符
memcpy需要你来指定拷贝的长度,他不检查/0结束符
strcpy两个参数
memcpy三个参数
strcpy效率低
memcpy效率高
-------------------------------------------------
strcpy的参数是字符指针(字符串)
memcpy的参数是void指针,因此它不仅能复制字符串,而且可以复制其它类型的数据(但要给出复制的字节数)
char *strcpy(char *to, const char *from)
{
char *ret = to;
assert(to != NULL && from != NULL);
while (*from != '\0')
{
*to = *from;
to++;
from++;
}
*to = '\0';
return p;
}
void *memcpy(char *to, const char *from, size_t size)
{
char *ret = to;
assert(to != NULL && from != NULL);
while (size > 0)
{
*to = *from;
to++;
from++;
size--;
}
return ret;
}
-----------------------------------------------
3.strlen
char \0结束
阅读(945) | 评论(0) | 转发(0) |