gint to gchar: g_sprintf



I am beginner with C/GTK. I am trying to convert an integer to a gchar. I am 
using this code.

gint add = 10;
g_sprintf(gchar *addid,"%d", add);
gchar *sqlstring = "INSERT INTO ADDRESSES (addid, fname, lname, phone, 
emailid, comment) values (\'";
sqlstring = g_strconcat(sqlstring, addid, "\',\'", fn, "\',\'", ln, "\',\'", 
ph, "\',\'", id, "\',\'", com, "\')", NULL);
g_print("String: %s\n", sqlstring);

The error follows ... It says g_sprintf's declaration is implicit? I have 
included glib.h rest i think glade has done linking with right libraries and 
supplying include paths. What could be wrong?

bash-2.05b$ make
source='callbacks.c' object='callbacks.o' libtool=no \
depfile='.deps/callbacks.Po' tmpdepfile='.deps/callbacks.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/gtk-1.2 -I/usr/include/glib-
1.2 -I/usr/lib/glib/include -I/usr/X11R6/include    -g -O2 -Wall -c `test -
f 'callbacks.c' || echo './'`callbacks.c
callbacks.c: In function `dbase_add':
callbacks.c:18: warning: implicit declaration of function `g_sprintf'
callbacks.c:18: parse error before "gchar"
callbacks.c:20: `addid' undeclared (first use in this function)
callbacks.c:20: (Each undeclared identifier is reported only once
callbacks.c:20: for each function it appears in.)
callbacks.c:17: warning: unused variable `add'
make: *** [callbacks.o] Error 1

How should I convert a gint to gchar?

Regards
Sukrit





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]