title: C programming string parsing
body: <p>I am parsing a macro definition from a Makefile into two strings, the name of the macro and the body. For example here is a macro definition line from my Makefile:</p>
  
  <p>macro-1 = body-1   </p>
  
  <p>My code produces a bus error/segmentation fault.</p>
  
  <pre><code>static void parse_macro_def(const char* line)
  {
     char* m_name;
     int name_pos = 0;
  
     int i = 0;
     while(line[i++] != '=')                    //iterate until an equal sign is found
     {
        if(!isspace(line[i]))          //copy characters to m_name  unless the character is whitespace
        {
           m_name[name_pos++] = line[i];
        }
     }
  }
  m_name[name_pos] = '\0';
  </code></pre>
  
  <p>m_name should be set to macro-1
  Thanks for all the help!</p>