先上一段代码
#include <iostream>
#include <string.h>
using namespace std;
struct key
{
string test;
};
int main()
{
struct key kk;
memset(&kk, 0 , sizeof(struct key));
kk.test = "aa";
return 0;
}
在vs上运行上面这段代码,不会报错。
在linux运行就会,在下面这个地方段错误
kk.test = "aa";
原因参考