I’ve got an array of characters which contains a string:
char buf[MAXBUFLEN];
buf[0] = 'f';
buf[1] = 'o';
buf[2] = 'o';
buf[3] = '\0';
I’m looking to pass this string as an argument to the gtk_text_buffer_insert function in order to insert it into a GtkTextBuffer. What I can’t figure out is how to convert it to a const gchar *, which is what gtk_text_buffer_insert expects as its third argument.
Can anybody help me out?
gcharis just atypedefforcharand the conversion from arrays to const pointers is implicit, so you can just pass it:Note that you can also directly initialize arrays with string literals: