I'm writing a simple C app with GTK2.
I have a little problem - I must create a 9x9
table of entry widgets, so I think it is a good idea to create an array of GtkWidget
s and use it in loops etc.
But... my program crashes when I pass an element of this array to a GTK function.
I declare the array like this:
GtkWidget* entries[9][9];
later, I have a function:
void drawBoard(GtkWidget* table, GtkWidget* entries[][9])
{
for(last_i=1; last_i<10; last_i++)
{
for(last_j=1; last_j<10; last_j++)
{
addField(entries[last_i-1][last_j-1],table);
}
}
}
And finally in addField
I use the entry like this:
void addField(GtkWidget* field, GtkWidget *table)
{
field = gtk_entry_new_with_max_length(1);
//rest of code
}
Afterwards, when I try to access the elements I initialized in the code above, the program crashes, for example:
void function(GtkWidget *entries[][9])
{
int i,j=0;
for(i=0; i<9; i++)
{
for(j=0; j<9; j++)
{
gtk_entry_set_width_chars(entries[i][j], 2);//<-- here app crashes
}
}
}