title: How to store characters into a char pointer using the strcpy() function
body: <p>I am trying to figure out why I can't store characters into my char pointer by using the strcpy() command. I get a seg fault when I run the code below.</p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;string.h&gt;                                                                  
  
  int main(int argc, const char *argv[])                                               
  {                                                                                    
     char *str1, *str2;                                                               
     int ret;                                                                         
  
     strcpy(str1, "abcdefg"); // stores string into character array str1              
     strcpy(str2, "abcdefg");                                                         
  
     printf("contents of %s \n", str1);                                               
  
     ret = strncmp(str1, str2, strlen(str2)); /* compares str1 to str2 */             
  
     if (ret &gt; 0) {                                                                   
         printf("str1 is less than str2\n");                                          
    }                                                                                
    else if (ret &lt; 0) {                                                              
        printf("str2 is less than str1\n");                                          
    }                                                                                
    else if (ret == 0) {                                                             
        printf("str1 is equal to str2\n");                                           
    }                                                                                
  
    return 0;                                                                        
    }   
  </code></pre>
  
  <p>Thank you!</p>