title: Pass pointer of struct
body: <p>I have code like this</p>
  
  <p>main.c</p>
  
  <pre><code>....
  ....
  struct dta
  {
      int id;
      char *val;
  };
  ....
  ....
  int main(void)
  {
      struct dta *dt = malloc(sizeof(*dt));
      dt-&gt;id=8;
      dt-&gt;val=strdup("123456qwerty");
  
      foo1(dt);
  
      free(.........);
      free(.........);
  
      return 0;
  
   }
  
  void foo1(struct dta *dt)
  {
      foo2(dt);
  }
  
  void foo2(struct dta *dt)
  {
      foo3(dt);
  }
  
  void foo3(struct dta *dt)
  {
      free(dt-&gt;val);
      dt-&gt;val=strdup("asdfg123456");
      dt-&gt;id=18;
      bar(dt);
  }
  
  void bar(struct dta *dt)
  {
      printf("id = %d\n", dt-&gt;id);
      printf("val = %s\n", dt-&gt;val);
  }
  </code></pre>
  
  <p>I do not know what to do, I just learned c language. I want to display the data dt->* that I created in main () to bar (). Firts, I have dt->* from main, I call and pass dt->* to foo1(), foo1() call foo2() and pass dt->* to foo3(). And I want to print dt->* from bar(). Please someone help me. The problem is foo3() can't update dt->* on main().</p>