Printf From A Void Or Int Sub Routine

Printf Command Isnt Displayed/Run In Subroutine Till I close Window

Page 1 of 1

1 Replies - 801 Views - Last Post: 08 May 2009 - 03:50 PM Rate Topic: -----

#1 Arkwind  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-November 08

Printf From A Void Or Int Sub Routine

Post icon  Posted 08 May 2009 - 03:22 PM

Hi There

Im having a problem - i am coming back to C from about 4 years off and need some help figureing something out - i have a GTK button pressed rigged to run a subroutine that prints the data passed to it - however the sub routine isnt printing anything until i close the window, how can i solve this so it prints upon the button press?

int lastspin(char *number, char *rbg, char *evodd, char *hl)
{
printf("Number %s Colour %s Even/Odd %s High/Low %s", number, rbg, evodd, hl);
return 0;
}


void closeApp ( GtkWidget *window, gpointer data)
{
gtk_main_quit();
}

gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
return FALSE;
}

int button0_clicked(GtkWidget *button0, gpointer data)
{
	lastspin("0","GREEN","EVEN","NA");
}



Thanks - its probably something small so sorry for bothering you :-)

Is This A Good Question/Topic? 0
  • +

Replies To: Printf From A Void Or Int Sub Routine

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Printf From A Void Or Int Sub Routine

Posted 08 May 2009 - 03:50 PM

The output stream is not getting flushed until the window closes. You can use fflush(stdout); to flush it.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1