title: Pass a dynamic array from inside one function to other in C
body: <p>If I created a dynamic array inside a function and insert values in it, and I want to use this array in other function, but I want its values not to be destroyed, should I declare it as a static and as an extern? If so how do I do this?</p>
  
  <p>For example:</p>
  
  <h3>a.c</h3>
  
  <pre><code>void func1(void)
  {
      char *filename;
      file_name=(char *) malloc ((SIZE)*sizeof(char));
  
      strcpy(file_name , other_file_name); 
      file_name[N-1] = '\0'; 
      file_name[N-2] = 'x';
  
  bla bla
  } 
  </code></pre>
  
  <h3>b.c</h3>
  
  <pre><code>void func2(void)
  {
  operations on file_name
  }
  </code></pre>
  
  <h3>my_main.c</h3>
  
  <pre><code>#include &lt;stdio.h&gt;
  MORE INCLUDES HERE
  
  #include "a.h"
  #include "b.h"
  int main()
  {
  
  bla bla ...
  
  return 0;
  }
  </code></pre>
  
  <p>This is the purpose, but should I declare inside func1() <code>static extern char *filename;</code>?
  And if it's the right way, what else should I do in order for it to work?</p>