我写了下面这段代码,得到了上面提到的错误
有人能告诉我哪里出错了吗
谢谢。
#include "iostream"
#include "sstream"
#include <string.h>
int main()
{
std::string temp1 = "454552354772";
char arr[16];
memcpy(arr , &temp1 , temp1.size());
std::string temp2;
memcpy(&temp2 , arr , temp1.size());
std::cout<<temp2;
}
我得到的错误是
*** Error in `./a.out': double free or corruption (fasttop): 0x00000000016c5010 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80a46)[0x7fa91d359a46]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSsD1Ev+0x20)[0x7fa91dc78290]
./a.out[0x400bc9]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fa91d2faea5]
./a.out[0x400a09]