struct node
{
char *ptr = (char *)malloc(frames*sizeof(char));
}*start,*current;
然后我分配了等于 node
的内存来启动。
[...]//Assigned values to start node.
current = start;//Current points to start
node *temp = new node();//temp will point a newly created node
*temp = *current;// COPYING VALUES OF CURRENT TO TEMP
[...]
我想创建一个新节点,让 temp
指向它,并将 current
的值(这里 current 指向 start)复制到 temp。
但这是使临时点 current
(此处为 start
)。
沮丧的。我哪里错了?
最佳答案
*temp = *current
应该是 temp = current
。
关于c++ - 等于指针值正在改变指针引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21882102/