There is indeed an easier way to do this.
The popen() function opens a pipe to a command. This will execute the command and allow you to either write to it (appearing as the command's stdin) or read from it (you read its stdout). Some documentation:
Pipe to a Subprocess - The GNU C Library
Once you've done this, you can read the output via fgets(). And finally, you can add it into your new command with sprintf().
As for the system() function, first off, this is not a "system call". A system call is a function that hooks directly into the kernel. You can use the syscall() function to do so directly, or you can use a glibc wrapper (for instance, the chmod() function).
In any event, system() is used when you want to run a command for its side effect, not for its input or output. system() opens up a new instance of the shell and runs the program. When you want I/O from the new process, popen() is your friend; when you want deep control over the new process, the fork()/exec combo is your friend.
I hope that helps!
EDIT:
It just dawned on me that you're using C++. You can definitely use all of the above (they are Linux C, and you can use C from C++), but if you're looking for a pure C++ solution, you might try Googling for a C++ wrapper around popen(). You can also use popen() and such, and then when you get the PID as a char*, convert it to an std::string.
Alternatively, we can continue with your approach above. You have the PID in a variable, you now need to make a string. You can use string streams to construct a string with the PID in it, and then use that string in your system() function:
C++ String Streams