c++ - 等于指针值正在改变指针引用

标签 c++ pointers struct nodes

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/

相关文章:

c++ - 高级rgb2hsv转换Matlab到opencv/C++获取像素值

c++ - 从python/子进程调用另一个进程需要访问shell

c++ - cmake 不可见 Visual Studio 编译器

java - Java 中的私有(private)变量和 C++ 结构中的私有(private)变量有什么区别?

c++ - 这是系统资源吗? (或者我怎么知道我是否需要删除指针)- 在 C++ 中使用 C

c - 解码 C 声明并使用它

c - 如何在运行时分配多维数组?

c# - c++ dll结构到c#

c - 取消引用指向不完整类型的指针 ‘struct'

c - 错误: redefinition of typedef in c