title: Malloc attempts to address 0x0?
body: <p>I'm working with dynamic memory in C. I'm writing a small function which should</p>
  
  <ol>
  <li>take a string (a char*) as a parameter;</li>
  <li>allocate memory with malloc for that string, copy it into the memory; and</li>
  <li>return the newly allocated string.</li>
  </ol>
  
  <p>My program gives a segmentation fault.</p>
  
  <pre><code>char *new_line(char *line) {
          char *temp_line;
          int line_len = strlen(line)+1;
          temp_line = malloc(line_len * sizeof(char));
          printf(temp_line);
          strncpy(temp_line,line,line_len);
          return temp_line;
  }
  </code></pre>
  
  <p>According to GDB, my program fails on this function, because apparently it is trying to do something (?) to the address 0x0.
  This is what GDB says:</p>
  
  <pre><code>#0  0x00007ffff7b7c3c1 in __strlen_sse2_pminub () from /lib64/libc.so.6
  #1  0x00000000004008fc in new_line (line=0x0) at myfile.c:35
  </code></pre>
  
  <p>Can anyone offer some insight on why malloc seems to be returning or messing with 0x0, based on my function? I can't see it.</p>