首先,请看cplusplus里对strcpy( )函数原型的说明:- 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 Value
destination is returned.
我犯错误大概是这样的:
- #include <iostream>
-
-
#include <string.h>
-
-
#include <string>
-
-
using namespace std;
-
-
-
-
int main() {
-
-
cout << "!!!Hello World!!!" << endl; // prints !!!Hello
-
-
char str[5];
-
-
strcpy(str, "12345");
-
-
cout << str << endl;
-
-
return 0;
-
-
}
然后在Debug是,出现如下错误提示:
- warning: .dynamic section for "/lib/libm.so.6" is not at the expected address
-
-
warning: difference appears to be caused by prelink, adjusting expectations
-
-
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address
-
-
warning: difference appears to be caused by prelink, adjusting expectations
但是控制台不会输出warning或者error,程序调试完成,会报错:
No source available for "__libc_start_main() at 0x4cee9c"
如果程序执行,则不会报任何错误!!
真可怕。
阅读(1077) | 评论(0) | 转发(0) |