title: C - Why is my function returning NULL?
body: <p>I think my function is returning <code>NULL</code> since I initilize it to it. But I get compiling error if I dont.</p>
  
  <p>This is just a prototype that I made in a <code>test.c</code> file to test it. So when I get it to work I will copy back the <code>lookup</code> function back into the correct file. </p>
  
  <p>This is part of <code>pset6</code> of <code>cs50</code> if that helps anyone.</p>
  
  <pre><code>const char* lookup(const char* extension);
  
  int main(void)
  {
      const char* type = "css";
      const char* ending = lookup(type);  
      printf("the exstension: %s\nis of type = %s\n", type, ending);
  }
  
  const char* lookup(const char* extension)
  {
  
      char temp[strlen(extension)];
  
      for (int i = 0; i &lt; strlen(temp); i++)
      {
          if (isalpha(extension[i]))
              temp[i] = tolower(extension[i]);
      }
  
      printf("temp = %s\n", temp);
  
      char* filetype = NULL;
  
      if (strcmp(temp,  "html") == 0)
          strcpy(filetype, "text/html"); 
  
      else if(strcmp(temp, "css") == 0)
          strcpy(filetype, "text/css");
  
      else if(strcmp(temp, "js") == 0)
          strcpy(filetype, "text/js");
  
      else if(strcmp(temp, "jpg") == 0)
          strcpy(filetype, "image/jpg");
  
      else if(strcmp(temp, "ico" ) == 0)
          strcpy(filetype, "image/x-icon");
  
      else if(strcmp(temp, "gif") == 0)
          strcpy(filetype, "image/gif");
  
      else if(strcmp(temp, "png") == 0)
          strcpy(filetype, "image/png");
  
      else
          return NULL;
  
      return filetype;
  }
  </code></pre>
  
  <p>I'm using all the correct libraries, it screwed up my code preview when I tried to include them!</p>