全部博文(685)
分类: 嵌入式
2014-05-09 09:56:20
二级指针应用:
CHAR **ppstResult;
*ppstResult = (CHAR *)VOS_Malloc(PID_CWMP, CWMP_BUILDRUNBUF);
VOS_MemSet(*ppstResult, 0x0, CWMP_BUILDRUNBUF);
VOS_Mem_Copy(*ppstResult, "\r\n Error: The password length must be less than 256.",VOS_strlen("\r\n
Error: The password length must be less than 256.")+1);
**ppstResult = '\0';----错误,指针未移到结尾就赋结束符。
/**
* strcpy - Copy a %NUL terminated string
* @dest: Where to copy the string to
* @src: Where to copy the string from
*/
char * strcpy(char * dest,const char *src)
{
char *tmp = dest;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}
#endif
#ifndef __HAVE_ARCH_STRNCPY
/**
* strncpy - Copy a length-limited, %NUL-terminated string
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @count: The maximum number of bytes to copy
*
* Note that unlike userspace strncpy, this does not %NUL-pad the buffer.
* However, the result is not %NUL-terminated if the source exceeds
* @count bytes.
*/
char * strncpy(char * dest,const char *src,size_t count)
{
char *tmp = dest;
while (count-- && (*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}