C Structs Nodes -


I was given a project to do my work in C, but my professor did not teach anything about C , So I'm just trying to learn as I go.

How do I specify the value in different parts of the node?

The main code that is running with me: (This was given in the assignment)

  Node N2, N3, N4, Times, Plus; Setnode (and n2, 2, noull, null, true); Setnode (and n3, 3, null, tap, true); Setnode (and N4, 4, Nouel, Nouel, True); Printf ("\ n"); Setnode (& amp; bar, '*', and n3, and n4, true); Setnode (& amp; plus, '+', & amp; 2; & amp; bar; true); Printf ("Tree Evaluation:% d \ n \ n", Evil (& amp; Plus));   

and in the header file:

  type -file structure Node_t {int value; Struct Node_t * left; Struct Node_t * right; } Node, * node_p;   

What is setNode for now:

  zero setnode (node_p np, int value, node_p left, node_p right, butle display) {np - & Gt; value; }   

How do I fill the values ​​for left and right? And how do I access them to any other method eval ?

I am googling for days and can not understand what I am seeing. I know Obj-C very well, but it's just on my head. Any answers or links to resources will be awesome

Looking at a node_p struct is an indicator for node_t , you can access the members of the object using the arrow operator ( -> ) then setNode () function, you can set the left and right the way you are signed in and value

  Zero setnode (Node_p np, int value, Node_p left, Node_p right, bool display) {np- & gt; Value = value; / * Sets the value field * / np- & gt; Left = left; / * Sets the left field * / np- & gt; Right = right; / * Sets the correct fields * / / * and so on ... * /}   

Note that if there is an indicator for any string or union object in general.

How eval () was used, it seems that it also takes a Node_p , to reach the members, this same It is done in a manner that, like using the arrow operator, you may be reading values, do not set them up.

For example,

  Zero Eval (Node_p np) {int value = np- & gt; Values; / * Value field * / Node_p left = np- & gt; Left; / * Left field * / node_p right = np- & gt; Right; / * Read correct field * /}    

Comments