process on file

Hello,

I need to write this C program:

MyProgram <user>

that write on myfile.txt file all <users> 'process.

MyProgram must call the ps -u <user> command, but with an exec or with a system?

can any one help me?

Thank you