This sort of thing is more easily done in Perl, but here's some C code to do it.
#include <sys/types.h>
#include <unistd.h>
pid=fork();
if(pid<0)
{error}
if(pid==0){
// child code;
exit;} // remember to include exit so child terminates
else{
// parent code
}