If you do system("cd ... ; ./test.exe"); and the directory does not exist, let's say for the sake of argument, it will still try to attempt to run ./test.exe, and the script will fail also by the way.
–
AndersJan 17 '11 at 22:38

Or worse, it will execute the wrong test.exe.
–
larsmansJan 18 '11 at 15:22

I'm going to ignore the use of the system function, and answer as if the pipeline command was typed at the command line, for the sake of making this point:

When you create a pipeline like cd somedir | ./test.exe, the shell is allowed to run each command of the pipeline in a separate subshell environment. Furthermore, there's no guarantee that they'll execute in strict left-to-right order. So the cd command doesn't affect the environment of test.exe in the way you're expecting. cd, being a shell builtin, can only affect the environment of the shell it's executed in, which in this case would be a subshell created as part of setting up the pipeline, not the shell into which the pipeline command was typed.