Chinaunix首页 | 论坛 | 博客
  • 博客访问: 476547
  • 博文数量: 98
  • 博客积分: 3265
  • 博客等级: 中校
  • 技术积分: 1227
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-23 00:29
文章分类

全部博文(98)

文章存档

2012年(6)

2011年(83)

2010年(9)

分类: C/C++

2011-11-28 15:44:40

#include //printf
#include //ssert
#include //malloc
#include //strlen

char * sstrcpy(char * strdst, char * strsrc)
{
char *dst = strdst;
assert(strdst!=NULL && strsrc!=NULL);
while((*strdst++ = *strsrc++)!= '\0')
NULL;
return dst; //实现链式表达式
}

//int num = strlen(strcpy(strdst,"hello world"));

int main(void)
{
int num;
char *strdst = (char *)malloc(sizeof(char)*100);

if(strdst == NULL)
return (-1);
num = strlen(sstrcpy(strdst,"hello world"));
printf("%d\n", num);

return 0;
}
阅读(2242) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~