title: C Structs Nodes
body: <p>I was just assigned a project to do in C in my class, but my professor didn't teach anything about C, so I'm just trying to learn as I go.</p>
  
  <p>How do I assign values to different parts of a node?</p>
  
  <p>The main code that runs I have is: (This was given in the assignment)</p>
  
  <pre><code>Node n2, n3, n4, times, plus;
  
  setNode(&amp;n2, 2, NULL, NULL, true);
  setNode(&amp;n3, 3, NULL, NULL, true);
  setNode(&amp;n4, 4, NULL, NULL, true);
  
  printf("\n");
  
  setNode(&amp;times, '*', &amp;n3, &amp;n4, true);
  setNode(&amp;plus,  '+', &amp;n2, &amp;times, true);
  
  printf("  Tree evaluation: %d\n\n", eval(&amp;plus));
  </code></pre>
  
  <p>and in the header file:</p>
  
  <pre><code>typedef struct Node_t {
      int             value;
      struct Node_t   *left;
      struct Node_t   *right;
  } Node, *Node_p;
  </code></pre>
  
  <p>What I have so far for setNode is:</p>
  
  <pre><code>void setNode(Node_p np,
           int    value,
           Node_p left,
           Node_p right,
           bool   display) {
  
  np-&gt;value;
  }
  </code></pre>
  
  <p>How do I fill in the values for left and right? And how do I access them in another method <code>eval</code>?</p>
  
  <p>I've been googling for days and can't figure out what I'm exactly looking for. I know Obj-C pretty well, but this is just over my head. Any answers or links to resources would be awesome. </p>