title: How to call a function using if statement and then print the value inside the function
body: <p>I'm new to C programming language and when I'm practicing using struct, I cannot print the struct value inside a function using an if statement, it prints the memory address(I think). But when I tried to call the function without an if statement it works just fine.
  This is the code using an if statement</p>
  <pre><code>#include &lt;stdio.h&gt;
  typedef struct{
      int age[10];
      int input;
  }data;
  
  int inputData(){
      data inputData;
      int i;
      printf(&quot;Total Data :&quot;);
      scanf(&quot;%d&quot;, &amp;inputData.input);
      for(i=1;i&lt;=inputData.input;i++){
          printf(&quot;Input your age :&quot;);
          scanf(&quot;%d&quot;, &amp;inputData.age[i]);
      }
      return main();
  }
  
  void viewData(){
      data viewData;
      int i;
      for(i=1;i&lt;=viewData.input;i++){
          printf(&quot;%d&quot;, viewData.age[i]);
      }
      
  }
  int main(){
      int menu;
      printf(&quot;Input menu :&quot;);
      scanf(&quot;%d&quot;, &amp;menu);
      if(menu==1){
          inputData();
      }else if(menu==2){
          viewData();
      }
  }
  </code></pre>
  <p>And this is the output</p>
  <pre><code>Input menu :1
  Total Data :2
  Input your age :21
  Input your age :31
  Input menu :2
  0853839645327661046072584004611648742404199977042107010648742008541535363276664803040725840046264875200419984104210701064874800854153536327666480368002131327661046
  </code></pre>
  <p>However when I delete the return main() inside the <strong>inputData</strong> function and change the <strong>int main</strong> to:</p>
  <pre><code>int main(){
      inputData();
      viewData();
  }
  </code></pre>
  <p>It works just fine. Output:</p>
  <pre><code>Total Data :2
  Input your age :21
  Input your age :31
  2131
  </code></pre>
  <p>Please help me to find a way to make the if statement code works. Any help would be appreciated, Thank you.</p>