| beggar 回复于:2003-03-02 21:30:01
|
高.
|
| seawolf1979 回复于:2003-03-03 00:00:35
|
高质量c_c++编程 里的,呼呼
|
| shanhan 回复于:2003-03-03 08:58:10
|
确实!
好利害哦!
|
| lucky123 回复于:2003-03-04 20:37:24
|
不错,不错!
佩服,佩服!
|
| Lanyd 回复于:2003-03-06 08:58:54
|
[color=red:21c64330fc]好,收藏![/color:21c64330fc]
|
| pcerma 回复于:2003-03-06 11:25:42
|
好,珍藏!
---------------
革命尚未成功,同志还需努力!
|
| liuyibing 回复于:2003-03-27 14:49:36
|
经典
|
| liuyibing 回复于:2003-03-27 14:53:44
|
经典
|
| likec 回复于:2003-08-12 00:19:09
|
是否仍然没有进行边界检查?如果strdest不足以容纳strsrc的话。
算是up一下。
|
| Joran 回复于:2003-08-13 19:55:03
|
呵呵,CSDN上的
[code:1:4b0e9c0285]
/* the emplementation in VC++ */
char* strcpy(char* dest, const char* src)
{
char* tmp = dest;
while (*tmp++ = *src++)
;
return dest;
}
/* the emplementation in Linux */
char* strcpy(char* dest, const char* src)
{
char* tmp = dest;
while ((*tmp++ = *src++) != '\0')
;
return dest;
}
[/code:1:4b0e9c0285]
|
| ldzyg 回复于:2003-08-22 00:46:15
|
[quote:b8a1538b5c="Joran"][/quote:b8a1538b5c] [color=red:b8a1538b5c][/color:b8a1538b5c][size=18:b8a1538b5c][/size:b8a1538b5c]这样应该没什么错误吧?
|
| quanliking 回复于:2003-08-23 01:23:49
|
[quote:4c19c1bfc9="Joran"][/quote:4c19c1bfc9]
引用有错误,贴这种教课书式的代码,还是得严谨些。
Linux 下的定义是这样的:
/usr/lib/string.h
[code:1:4c19c1bfc9]
string.h:
char *strcpy (char *__restrict __dest, __const char *__restrict __src)
__THROW;
[/code:1:4c19c1bfc9]
/usr/src/linux-2.6.0-test3/lib/string.c
[code:1:4c19c1bfc9]
/**
* 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;
}
[/code:1:4c19c1bfc9]
在 string.h 中有 __THROW 这个宏,我们来查看一下在哪里定义的:
$ grep __THROW /usr/include/*.h |grep define
[code:1:4c19c1bfc9]
...
usr/include/malloc.h:# define __THROW throw ()
...
[/code:1:4c19c1bfc9]
而且几乎每个预处理指令都由 __THROW 来处理,可以这样查看:
$ grep -R __THROW /usr/include/* | grep "#"
linux 里的和高质量C/C++ 里的其实是一样的,除了异常处理哪里稍不同而已。
|
| hangne 回复于:2003-09-11 11:04:03
|
[quote:b80f202c8d="HopeCao"]);
返回strSrc的原始值是错误的。其一,源字符串肯定是已知的,返回它没有意义。其二,不能支持形如第二例的表达式。其三,为了保护源字符串,形参用const限定strSrc所指的内容,把const char *作为char *返回?.........[/quote:b80f202c8d]
|