It only prints the description when I print b again after the if statement, really weird behavior, when I remove the last line it doesn’t print description is ...dos anyone know why this happens and how I can fix this? Thanks
char * b;
if (list!= NULL){
b = strdup ( (char *)g_object_get_data(G_OBJECT(list->data), "description") );
printf(" description is %s ", b);
}
printf("\nprinting b: %s\n", b);
It’s seems
stdoutis line-buffered, i.e.printfhoards output until it encounters a newline or its buffer fills up. Add a newline to the firstprintf:To ensure the output buffer is flushed, you can say: