Welcome to The C Continuum!
Even though this blog is called The C Continuum, it’s not only going to be about programming in C, I will probably talk about other languages (prolog, haskell, C++, python, …) and other topics (maths, physics, computer science, …).
But as we are in The C continuum, this introductory post will be dedicated to the first step in the process of learning a new programming language: the very simple, yet enlightening, Hello World! program:
#include <gtk/gtk.h> int main (int argc, char *argv[]) { GtkWidget *window, *label; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Hello World!"); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_widget_set_size_request(window, 210, 100); g_signal_connect(G_OBJECT(window), "destroy", gtk_main_quit, NULL); label = gtk_label_new("Hello World!"); gtk_container_add(GTK_CONTAINER(window), label); gtk_widget_show_all(window); gtk_main(); return 0; }
As you may already know, the code above is written in C and uses the GTK library to generate a graphical interface. If you wish to compile the code you can use the following command:
gcc -Wall `pkg-config --cflags --libs gtk+-2.0` hello.c -o hello
Enjoy!