Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2984884
  • 博文数量: 685
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5303
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-19 14:17
个人简介

文章分类

全部博文(685)

文章存档

2015年(116)

2014年(569)

分类: 嵌入式

2014-05-09 09:56:20

存放目录:uboot/lib/string.c

二级指针应用:
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;
}


阅读(981) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~