Listing 9. Source code for project HelloWorld01.

//Project HelloWorld01

#include <allegro.h>

int main(){

  allegro_init();//Allegro initialization

  install_keyboard();//Set up for keyboard input

  //Set the graphics mode to a 320x240-pixel window.
  set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320,240,0,0);

  //Draw text on the window.
  textout_ex(screen,//Specify bitmap on the screen
             font,//Use a default font
             "HELLO WORLD",//Specify the text to display
             20,//X-coordinate for text
             30,//Y-coordinate for text
             makecol(255,255,0),//Color text yellow
             makecol( 255,0,0) );//Put red behind text
    
  //Block and wait until the user presses a key.
  readkey();

  return 0;//Return 0 to indicate a successful run.
}//end main function

//The following macro is peculiar to Allegro.In order to
// maintain cross-platform compatibility, you have to put
// this macro at the very end of your main function.
END_OF_MAIN()