Re: gtk_main_quit () problem



I can see two blatent C errors, either of which could be causing you
bugs.  

First do NOT ever pass a const char * to strtok as its first argument.
Casting does not stop it from being a const char *.  You will need to
strdup the string first or use a non-destructive function like strspn.

Secondly 'gchar **parmv' is a pointer to pointer, not an array.  In
particular parmv[parm_counter] = parm is undefined in its behaviour. 

Note that my compiler generates a warnign on both of these errors, so
add some more warnings to compilation string, and makes sure you
understand what the compiler is complaining about.

        nash

/* event function 2*/
void run (GtkWidget *widget, GtkWidget *entry )
{
  const gchar *entry_text;
  gchar *parm;
  gchar **parmv;
  gint parm_counter = 0;
  gint ret_val;
 
  entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
  if (!(strcmp (entry_text, "")))
    return;

  /* tokenize the sting in all arguments */
  parm = strtok ( (char*) entry_text, (const char*) " ");
  while (parm != NULL)
  {
    parmv[parm_counter] = parm;
    parm = strtok (NULL, (const char*) " ");
    parm_counter++;
  }
  parmv[parm_counter] = (void*) NULL;
-- 
Brett Nash <nash nash nu>
Sometimes it's better to light a flamethrower than curse the darkness.



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