search

Home  >  Q&A  >  body text

Data Structure - Problems with pointer array assignment in C++?

As the title states, I defined a two-dimensional pointer array in Figure 1


The content of the address pointed to by each pointer in the two-dimensional array should be 1000
I also printed out the two-dimensional pointer later, and it was indeed 1000;
In the algorithm in the next picture, I plan to pay the weights of the edges between the nodes in the adjacency matrix to the pointer array, please see:


But every time I print the two-dimensional array again, the output value is still 1000. In order to confirm that the if condition is met, I also print out the weight value in front of it. . DEBUG as shown below


The bottom 81000. 8 is the weight of the edge between the first point and the second point. So why does the assignment fail?
Attach my other codes

Originally I planned to call it recursively, but it keeps looping in while, please help

曾经蜡笔没有小新曾经蜡笔没有小新2786 days ago671

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 13:23:23

    I haven’t seen the complete source code, so I can’t make a complete judgment.

    1. The place of assignment determines whether the condition is met. If it is not met, it means that the assignment statement is not executed at all.

    2. Whether the value obtained from the assignment place is correct.

    3. Whether what is printed is the position of the array you assigned.

    Suggestion: Set breakpoints for debugging to see if the execution process is correct and the values ​​of each variable are correct.

    reply
    0
  • Cancelreply