nice command and nice() system call

Hi I want to implement the nice command in the shell that I am building. I came to know that there is a corresponding nice() system call for the same. But since I will be forking different processes to run different commands typed on the command prompt, is there any way I can make a command execution call nice() first to adjust its priority?

eg nice 5 cp x y

makes cp increment its priority by 5

how can I make the execution of cp call nice() ?

One way:

 pid=fork();
 if(pid==0) 
 {
     nice();
     -- exec cp command here
 } 

hey thanks a lot jim.