pgrep returns 256

Hi Everyone,
I have a strange behaviour
In my c program i use this line:
int retval = system("pgrep encoder");
while i expect retval to contain 0,1,2,3
i get 256.
did i do something wrong?

thanks,
Alex

you expecting PID as 0,1,2,3???
because as far as i know pgrep [pattern]
will return PID of that active process..

the output of the command is the PID,
but the return value - which is what i'm getting is 0 or 1 or 2 or 3
according to the man
pgrep(1)