#include "gd.h"
#include "gdfontl.h"
#include <string.h>

function main()

... inside a function ...
gdImagePtr im;
int black;
int white;

/* String to draw. */
char *s = "Hello.";

im = gdImageCreate(100, 100);
/* Background color (first allocated) */
black = gdImageColorAllocate(im, 0, 0, 0);  
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);  
/* Draw a centered string. */
gdImageString(im, gdFontGetLarge(),
  im->sx / 2 - (strlen(s) * gdFontGetLarge()->w / 2),
  im->sy / 2 - gdFontGetLarge()->h / 2,
  s, white);
/* ... Do something with the image, such as 
  saving it to a file... */
/* Destroy it */
gdImageDestroy(im);

return