posts - 62,  comments - 19,  trackbacks - 0

1.实现一个字符串拷贝函数strcpy(char * a, char * b),b拷贝到a,用C语言实现,要求以性能为首要,请在程序中写上注释。

2.一个类拷贝的函数,要求用C写
例如:
class A {
int a;
public:
int b;
};

class B {
……
……
};

int main() {
A aa, bb;
B c, d;
a.a = 10; a.b = 20;
copyclass(???);// 将aa拷贝到bb
….
copyclass(???);// 将c拷贝到d
return 0;
}
3在一个项目中,你被分配到一个小任务:在一个字符串str中包含字符串str_a,找出所有在字符串str中的str_a,要求你架构这个功能块并且给出使用说明,代码运行健壮并且性能为首要。



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

1、while(*a++=*b++);
2、memcpy(&bb, &aa, sizeof(A));
memcpy(&d, &c, sizeof(B));
3、BOOL FindString(const char *src, const char *str_a)
{
   char *pStart=(char *)src;
   if(NULL==pStart || NULL==str_a) return FALSE;
   char *pCursor=pStart;
   while(pCursor=strstr(pCursor, str_a))
  {
     printf("find (%s) at position %ld\r\n"), str_a, pCursor-pStart);  
  }
  return TRUE; 
}

posted on 2007-03-05 17:13 乔栋 阅读(250) 评论(0)  编辑 收藏 引用 所属分类: C的游乐园

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2007年3月>
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜


My blog is worth $0.00.
How much is your blog worth?