title: C - Add space inside brackets
body: <p>So I am doing something wrong with this program and would like someones help. I want to add spaces between the brackets and the words inside. For instance if the original string is <code>if (x=5)</code> then I want to make it <code>if ( x=5 )</code>. Simple task I know and here is the code I have: </p>
  
  <pre><code>char* addSpaces(char* line) {
  
      int i,j;
      char *result = line;
  
      for (i = 0, j = 0; i&lt;strlen(line); i++,j++)          
      {
          if (line[i] == '[') {
              result[j] = line[i];
              j++;
              result[j] = ' ';
          }  
          else if (line[i] == ']') {
              result[j] = ' ';
              j++;
              result[j] = line[i];
          }                 
          else result[j] = line[i];                                        
      }
  
      result[j] = 0;
  
      return result;
  
  }
  </code></pre>
  
  <p>For some reason it freezes when I run the program. I don't get any errors. Any ideas?</p>