I have a variable of type char[] and I want to copy NSString value in it. How can I convert an NSString to a char array?
I have a variable of type char[] and I want to copy NSString value in it. How can I convert an NSString to a char array?
Rather than getCharacters:range:, I use:
[stringToCopy getCString:c_buffer maxLength:c_buffer_length encoding:NSUTF8StringEncoding];
The result is a char[] (instead of unichar[]), which is what the OP was wanting, and what you probably want to use for C compatibility.