struct的memset使用问题
我定义的struct:
struct qpool
{
map<string,struct queuex *> qmap;//map<string qname,int fd>
map<string,struct topicx *> tmap;//map<string qname,int fd>
};
int main(int argc,char **argv)
{
struct qpool qpl;
memset(&qpl,0,sizeof(qpl));
init(&qpl);
...
return 0;
}
当init(struct qpool *)函数使用qpl时,程序会报段错误。
如果我取消memset(&qpl,0,sizeof(qpl)),就可正常运行。这是为什么。
编译环境是linux,使用g++