c++ - difference b/w **ptr and *ptr -


I have basic knowledge about pointers that they point to memory and to change and remove them The values ​​stored on that address can be used for example

  int a = 5; Int * b; B = & amp; One;   

Now point to the memory spot of B here.

  cout & lt; & Lt; * B; // output 5 cot and lt; & Lt; B; // Address of the output   

In fact for the purpose and in the tasks and the structure of data such as linked lists and passing the values ​​of trees. Main () {node * head = NULL; // Add a pointer major of type node structure (and head, 2); // link for linked value added} Add zero (node ​​** head, int data) {// add value to node}

Can someone tell me why & Amp; Head is added (in the form of head) (**) in the function.
Besides, what did it do, it was received as head *?

When I print the value of the head ** I have a compiler error

Type of node *, when you get the address of the node (and the head), the type is node in **

The difference between node ** and node * is similar to int * and int Defines a second type of indicator.

The add method gets an indicator because it can change the value of the head if the head is faucet, then it should create a new node and specify the head at the address of this new node . If it only inputs the node head, then head = mallok (...) will not work because c passes through value and it defines "main" within the function, not the head in the head. But if the head gets the address of the head, then it can freely change it using the indicator like * head = malloc (...)

so that you do not actually print its value (Well, you can if you put it but it will not be anything meaningful). You need to enter it

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -