title: Initializing a struct results in Segmentation Fault
body: <p>I have a simple <code>struct</code> as follows:</p>
  
  <pre><code>typedef struct {
    char *raw_headers;
    char headers[128][512][512];
  } HTTPrequest;
  </code></pre>
  
  <p>Now in the same file I have a function as follows:</p>
  
  <pre><code>void init_request(char *raw_headers) {
    HTTPrequest request;
    request.raw_headers = raw_headers;
  }
  </code></pre>
  
  <p>This results in a Segmentation Fault when running the output binary.</p>
  
  <p>I compile the file, as</p>
  
  <pre><code>$ gcc Server.c -o Builds/debug
  </code></pre>
  
  <p>And, I run the executable as,</p>
  
  <pre><code>$ ./Builds/debug
  </code></pre>
  
  <p>This is my original file as requested:</p>
  
  <h2>Parser.h</h2>
  
  <pre><code>typedef struct {
    char *raw_headers;
    char headers[128][512][512];
  } HTTPrequest;
  
  void parser_init(char *raw_headers) {
    char *token, *key_value = NULL;
    token = strtok(raw_headers, "\r\n");
  
    int line_counter = 1
    HTTPrequest request;
    request.raw_headers = raw_headers;
  
    while (token) {
      char *line = token;
  
      if(line_counter != 1) {
      }
  
      token = strtok(NULL, "\r\n");
      line_counter++;
    }
  }
  </code></pre>
  
  <h2>Server.h</h2>
  
  <pre><code>int socket_create() {
    return socket(AF_INET, SOCK_STREAM, 0);
  }
  
  void infinite_loop(int socketFD) {
    char buffer[1024];
    memset(buffer, 0, sizeof(buffer));
  
    printf("Starting infinite loop, don't worry, everything would be okay!\n");
    do {
      int connectionFD = accept(socketFD, (struct sockaddr*) NULL, NULL);
      /*Accept is a blocking call! The following code wont execute until, accept() returns.*/
      strcpy(buffer, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nHello!");
      write(connectionFD, buffer, sizeof(buffer));
  
      char request[2048];
      memset(&amp;request, 0, sizeof(request));
      read(connectionFD, &amp;request, sizeof(request));
  
      printf("Request received!\n");
      // Init the parser.
      parser_init(request);
  
      close(connectionFD);
    } while (true);
  }
  </code></pre>
  
  <h2>Server.c</h2>
  
  <pre><code>#include &lt;sys/socket.h&gt;
  #include &lt;netinet/in.h&gt;
  #include &lt;arpa/inet.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;string.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;stdbool.h&gt;
  #include "Parser.h"
  #include "Server.h"
  
  void main() {
    struct sockaddr_in listeningAddr;
  
    int socketFD = socket_create();
  
    memset(&amp;listeningAddr, 0, sizeof(listeningAddr));
  
    listeningAddr.sin_family = AF_INET;
    listeningAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    listeningAddr.sin_port = htons(8070);
  
    bind(socketFD, (struct sockaddr*) &amp;listeningAddr, sizeof(listeningAddr));
  
    if(listen(socketFD, 5) == -1) {
      printf("Woah there! I couldn't startup the server!");
    }
  
    infinite_loop(socketFD);
  }
  </code></pre>
  
  <p>Also, the error message: <code>Segmentation fault (core dumped)</code></p>