Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dipaliP

macrumors newbie
Original poster
Oct 6, 2008
28
0
I have following string
NSString *stmt = [NSString stringWithFormat:mad:"INSERT INTO table (.....) VALUES (....), fields, values];
now i want to store this string into 'static char' variable as i want to insert some values into a table using sqlite3.
I am using following to convert string to 'const char'
const char *sql = [stmt UTF8String];
but i haven't get any idea to convert string to static char.

Any suggestion is acceptable.
Thanks in advance.
 
I have following string
NSString *stmt = [NSString stringWithFormat:mad:"INSERT INTO table (.....) VALUES (....), fields, values];
now i want to store this string into 'static char' variable as i want to insert some values into a table using sqlite3.
I am using following to convert string to 'const char'
const char *sql = [stmt UTF8String];
but i haven't get any idea to convert string to static char.

Any suggestion is acceptable.
Thanks in advance.

Diear brother i also facing this problem.. if you get any idea to solve this problem.. pls tell me dear......
 
call me stupid, but isn't a CHAR(acter) only ONE character. so you can only store an entire string in multiple char-variables, not in one, can you?

what does work is
Code:
unichar something = [yourString characterAtIndex:0];
 
call me stupid, but isn't a CHAR(acter) only ONE character. so you can only store an entire string in multiple char-variables, not in one, can you?

what does work is
Code:
unichar something = [yourString characterAtIndex:0];

Ah yes char is a single character, but a char* is a pointer to a character. Or the start of an array of characters...
 
First, let me recommend that you don't do that. Store your string as an NSString and convert it to const char * with [yourString UTF8String] at the moment that you use it. Why do you want to 'convert string to static char'?

Second, if you really want to store a char array then that's easy. Allocate your char array, with malloc or on the stack or as a global, and then strcpy the bytes from [yourString UTF8String].

Code:
strcpy(mycharbuffer, [yourString UTF8String]);

Third, use FMDB for sqlite access. It will make your life easier.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.