Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161779
  • 博文数量: 76
  • 博客积分: 1513
  • 博客等级: 上尉
  • 技术积分: 755
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-25 15:15
文章分类

全部博文(76)

文章存档

2012年(2)

2011年(74)

我的朋友

分类: C/C++

2011-11-25 19:34:39

首先,请看cplusplus里对strcpy( )函数原型的说明:
  1. char * strcpy ( char * destination, const char * source );

Copy string

Copies the C string pointed by source into the array pointed by destination, including the terminating null character.

To avoid overflows, the size of the array pointed by destination shall belong enough to contain the same C string as source (), and should not overlap in memory with source.

ParametersdestinationPointer to the destination array where the content is to be copied.sourceC string to be copied.
Return Valuedestination is returned.


我犯错误大概是这样的:
  1. #include <iostream>

  2. #include <string.h>

  3. #include <string>

  4. using namespace std;

  5.  

  6. int main() {

  7. cout << "!!!Hello World!!!" << endl; // prints !!!Hello

  8. char str[5];

  9. strcpy(str, "12345");

  10. cout << str << endl;

  11. return 0;

  12. }
然后在Debug是,出现如下错误提示:
  1. warning: .dynamic section for "/lib/libm.so.6" is not at the expected address

  2. warning: difference appears to be caused by prelink, adjusting expectations

  3. warning: .dynamic section for "/lib/libc.so.6" is not at the expected address

  4. warning: difference appears to be caused by prelink, adjusting expectations

但是控制台不会输出warning或者error,程序调试完成,会报错:

No source available for "__libc_start_main() at 0x4cee9c" 


如果程序执行,则不会报任何错误!!

真可怕。

阅读(1077) | 评论(0) | 转发(0) |
0

上一篇:博主的话

下一篇:关于ECM的某道面试题

给主人留下些什么吧!~~