Hi,
reading the php manual
http://www.php.net/manual/en/function.exec.php
you can use exec. If you supply an array as second argument the array would contain every line of output and you can use the array to do whatever you want.
The first argument is the complete path to your c++ program. You might want to use escapeshellcmd to if you call the program with user provided arguments (e.g. by submitting a form) to prevent the users to submit arguments to your program that would render your OS unuseable.