struct myclass
{
bool sexy;
char name[10];
};
myclass *people[1000];
void insert(pos,myclass newnode)//pos 位置
{
myclass *temp[1000];
memcpy(people,temp,sizeof(people));
temp[pos]=newnode;
for(int i=pos+1;i<1000;i++)
{
temp[i]=people[i-1];
}
}
void clearall()
{
for(int i=0;i<1000;i++)
{
people[i]=0;
}
}
//请问,为什么insert函数会出错?
{
bool sexy;
char name[10];
};
myclass *people[1000];
void insert(pos,myclass newnode)//pos 位置
{
myclass *temp[1000];
memcpy(people,temp,sizeof(people));
temp[pos]=newnode;
for(int i=pos+1;i<1000;i++)
{
temp[i]=people[i-1];
}
}
void clearall()
{
for(int i=0;i<1000;i++)
{
people[i]=0;
}
}
//请问,为什么insert函数会出错?
解决方案 »
- 各位帮忙,如何设定多双显示器显示模式为复制显示?
- vc++客房管理系统源码修改
- 请问namespace extension开发,toolbar上增加一个按钮如何捕获事件?
- 为什么VC6.0的代码不能放到VS2005里面编译成功!
- WaveInAddBuffer后如何释放内存
- 关于GetWindowRect获取不正确的值
- [求助]请教一个对话框之间通信的问题
- Release中调用DLL导出函数出现问题
- 如何自动模拟输入网页里编辑控件的内容,模拟点击网页里的按钮????
- 请问:对话框里的按钮怎样变灰失效?
- CTypedPtrArray 中的 RemoveAt后是否需要delete掉
- DockingBar上动态创建视图
{
bool sexy;
char name[10];
};
myclass *people[1000];
void insert(int pos,myclass *newnode)//pos 位置
{
myclass *temp[1000];
memcpy(people,temp,sizeof(people));
*temp[pos]=*newnode;
for(int i=pos+1;i<1000;i++)
{
temp[i]=people[i-1];
}
}
void clearall()
{
for(int i=0;i<1000;i++)
{
people[i]=0;
}
}
Unhandled exception at 0x00424df4 in xy.exe: 0xC0000005: Access violation writing location 0x00000000.这句出错了,
==》
temp[pos]=&newnode;
memcpy(people,temp,sizeof(people));这个没有问题?
它是 把 temp 复制到 people ...
应该是 memcpy(temp,people,sizeof(people)); 这样吧?