title: Using a struct vs a pointer to a struct
body: <p>I was working on the following as an example to see the differences between passing an object directly and then passing a pointer to it:</p>
  <pre><code>#include &quot;stdio.h&quot;
  
  // Car object
  typedef struct Car {
      char*           name;
      unsigned int    price;
  } Car;
  
  void print_car(Car car) {
      printf(&quot;&lt;Car: %s, Price: $%d&gt;&quot;, car.name, car.price);
  };
  
  void print_car2(Car *car) {
      printf(&quot;&lt;Car: %s, Price: $%d&gt;&quot;, car-&gt;name, car-&gt;price);
  };
  
  int main(int argc, char* argv[]) {
  
      Car chevy = {chevy.name = &quot;Chevy&quot;, chevy.price = 45000};
      print_car(chevy);
  
      Car mazda = {chevy.name = &quot;Mazda&quot;, chevy.price = 30000};
      print_car2(&amp;mazda);
  
      return 1;
  
  }
  </code></pre>
  <p>Other than the first approach being much more readable and easier to understand for me, what are the differences between the two? When would passing a pointer be the only option, and why do both work in the above case?</p>