Many of these exercises are taken from the book "Learn C The Hard Way".
gcc -o program main.c
By default, gcc will link against the C stdlib, which will cause errors. To remedy, tell gcc to link against the C++ stdlib.
gcc -o program -lstdc++ main.cpp