title: How to convert NSString to C string?
body: <p>I know that this question is a possible duplicate, but even after looking at some Google tutorials and questions even on this forum none of them gives me a decent answer about this subject.</p>
  
  <p>I have:</p>
  
  <pre><code>NSString *str = @"text";
  </code></pre>
  
  <p>And I would like to do something like:</p>
  
  <pre><code>char cstring [512] = str;
  </code></pre>
  
  <p>(this only shows what I want to do, after looking at Apple's NSString Class Ref I didn't even think about using it).</p>
  
  <p>Up to now I have:</p>
  
  <pre><code>char command [512] = [[NSString stringWithFormat:@"text"] cStringUsingEncoding:NSUTF8StringEncoding];
  </code></pre>
  
  <p>Still, with that I get errors.</p>
  
  <p>Any solution?</p>