Before you call execve(2) in the newly created process to execute the command, you can redirect its standard input or output via the dup2(2) system call:
/* redirect stdout to a file */
dup2(1, some_open_file_descriptor);
Of course, you need to have some error handling.