Sure. This example demonstrates cleaning up behind the pixel and not cleaning up behind the pixel. The principle is the same for a line. It also has a delay in the loop so that the animation slows down. Try playing around with it to see the differences.
Red pixel moves, blue pixel moves but leaves a tail. Press ESCape to quit.
int x; // X coordinate of our pixels.
// Initialize Allegro.
// Set the color depth to 32 bit.
// Set the resolution to 640 by 480 with SAFE autodetection.
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
// Installing the keyboard handler.
// Printing text to the screen.
textout(screen, font, "Moving Pixel:", 1, 1, makecol(255,0,0));
textout(screen, font, "Growing line:", 1, 22, makecol(0,0,255));
// Looping until the ESCape key is pressed.
// Erase old moving pixel.
putpixel(screen, x-1, 12, 0);
// Draw new moving pixel.
putpixel(screen, x, 12, makecol(255,50,50));
// Draw growing line from pixels.
putpixel(screen, x, 32, makecol(50,50,255));
rest(2); // Slow down animation.
// Exit program.
// Some Allegro magic to deal with WinMain().