title: How to dynamically allocate name array in C?
body: <p>I'm having some problems with dynamic allocation, because I don't want to specify the size of the array. Basically what I need in my program is to store a name of a file in an array and make sure it is not wasting space. </p>
  
  <p>I was trying to do something like creating the array <code>name[255]</code> to make sure it had enough space and then dynamically allocate it so it had only the required space, like writing "matrix5", then store it in <code>name[255]</code> and then change <code>name[255]</code> to <code>name[8]</code>. </p>
  
  <pre><code>char file_name[255];
  
  printf("what is the name of the file? [.txt]\n");
  scanf_s(" %s", file_name[255]); //store name eg: "matrix5"
  
  i = 0;
  char **fullpath;
  while (file_name[i] != '\0' &amp;&amp; i &lt;=strlen(file_name))
  {
      fullpath= (char**)malloc(sizeof(char*));  //In here it would then make file_name[255] into file_name[8]                             
      fullpath[i] = file_name[i];
      i++;
  }
  </code></pre>
  
  <p>What do I need to do here?</p>