Re: Variable Problem
- From: Jean Bréfort <jean brefort normalesup org>
- To: Wilton <wrwonrath yahoo com br>
- Cc: gtk-list gnome org
- Subject: Re: Variable Problem
- Date: Sat, 22 Oct 2005 14:58:08 +0200
Le samedi 22 octobre 2005 �0:54 -0200, Wilton a �it :
> Hi, I'm starting to program in C/GTK+ and I have a problem with a
> variable. Let me show the code and the error:
>
> /*-- Global Variables --*/
> char query_string[256];
> GtkWidget *entry_sql;
> .
> .
> .
>
> /*-- Do the instruction SQL --*/
> sprintf(query_string, entry_sql); // Build the instruction SQL
> res = PQexec(conn, query_string); // Send the SQL to the database
>
> I need to pass the value in GtkWidget *entry_sql to the char
> query_string[256] (a C variable), because when i compile it i receive
> the following error:
>
> [Warning] passing arg 2 of `sprintf' from incompatible pointer type
>
> How can i solve this problem?
The use of sprintf is dangerous since you might have a buffer overflow
unless you are absolutely sure that the cpied string will never be that
big.
Anyway, assuming that entry_sql is a GtkEntry*, you can use :
char const *query_sql;
query_sql = gtk_entry_get_text (GTK_ENTRY (entry_sql));
...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]