const char arr[]="Hello There";
I am trying to create a character array as above.
Below, is the code which I use. Is this a correct way to create a char array.
-(void) createCharArray:(NSString*) text{
char arr[text.length];
for(int i=0;i<text.length;i++){
arr[i]=[text characterAtIndex:i];
}
}
Do we have to worry about null termination? Do we have any other way to achieve the same?
You can use UTF8String
. Eg: [myString UTF8String]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With