What error messages did you get when you tried to compile your code? Did it complain about the symbols exexlp and prinf not being found? Did it complain about there not being any function prototypes for fork , wait , execlp , printf , exexlp , and prinf ?
If you actually got an executable file named example1 , why wouldn't you try executing ./example1 ? You showed us that you attempted to run ./first.c and there is no reason to think that a C source code file should be executable; but trying to execute it should have given you one or more diagnostic messages.
If you actually succeeded in running example1 (which, from what you have shown us, I doubt), is there an executable named yyy on your search path? Since you aren't checking the return codes on any of the functions you're calling, why would you believe that any of the functions you're calling are doing what you expected them to do?
I strongly suggest that you first get rid of all of the compilation warnings and errors in the code you're trying to compile before you try running any object file compiling it creates. Then try running the object file created; not the source file.
Sorry, I missed that. I was thinking that you got it from running example1 . What it wrong is that you can't execute source code. You have to compile it first and run the executable code that is produced from that source. But, as I implied with all of the questions about what errors you got when you tried to compile first.c (which you still haven't answered), I'm not at all surprised that you didn't get an executable file named example1 . Fix all of the errors in your source code (missing #include lines for the headers that contain the prototypes for the functions you're using, misspelled function names, incorrect types on function arguments, and strongly consider checking return codes on functions like wait , execlp , and fork .
Note that fork returns 0 in the child after a successful fork, -1 after a failed fork, and the PID of the child to the parent after a successful fork. Just checking for non-zero doesn't give you enough information to understand what is going on in your code.