title: Error while passing string in Network Programming in C
body: <p>I am implementing an HTTP server from scratch in C where I read a config file to get the path of the required file. But, when I read the file and pass it's value as a string to the function, I don't get <code>Segmentation fault (core dumped)</code> error.</p>
  <p>Attaching a few snippets of my code-</p>
  <pre><code>char index_loc[20];
  char const* const fileName = &quot;config.txt&quot;;
      FILE* file = fopen(fileName, &quot;r&quot;);
      if(!file){
          printf(&quot;\n Unable to open : %s &quot;, fileName);
          return -1;
      }
  fgets(index_loc, sizeof(index_loc), file);
  setHttpHeader(httpHeader, index_loc);
  </code></pre>
  <p>The function, <code> void setHttpHeader(char httpHeader[], char page[])</code> is working completely fine when I pass <code> setHttpHeader(httpHeader, &quot;index.html&quot;);</code> to it.</p>
  <p>Config file:-</p>
  <pre><code>8080
  index.html
  </code></pre>
  <p>The port number is being read correctly from the file.</p>