String with dinamicly growing buffer

String is where buffer overflow always occur.
GLIB supports doing this much more easily:

/* portable asprintf() */
char *str = g_strdup_printf("string%s%d", str_variable, int_variable);

Or if you wanted a modifyable buffer:

GString *str = g_string_new(NULL);
g_string_append(str, "string");
g_string_append(str, str_variable);
g_string_sprintfa(str, "%d", int_variable); /* no g_string_append_int() */

Secure, Efficient and Easy C programming


C variable definition

extern – Variables described by extern statements will not have any space allocated for them, as they should be properly defined elsewhere.

static – The static data type modifier is used to create permanent storage for variables. Static variables keep their value between function calls. When used in a class, all instantiations of that class share one copy of the variable.

const – The const keyword can be used to tell the compiler that a certain variable should not be modified once it has been initialized.

More C definition here

Using Makefile

If you writing gtk application. You will have to use more than one source file to make the code more manage able. To compile the application you need to use make.

makefile tutorial
makefile tutorial

It is all you need to compile a c code with libgnomedb. This code will output an executable
file with name ekoken. A more complicated makefiles using variable is like this

CC = gcc
LD = gcc
RM = rm -f
LDFLAGS = `pkg-config --libs gtk+-2.0`


all : $(PROG)

%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@

$(PROG) : $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $(PROG)

clean :
$(RM) $(OBJS) $(PROG)

Where PROG is the executable output and OBJS is the object file output with .o suffix.

You can read more from this link
Makefile in C or C++
A simple makefile tutorial