Unless you are prepared to resort to non-standard, platform-specific
solutions the only way you can do that is using the system() function
and have the external program write to a file. That file you read in
from the C program to get the output into your string.
But there's no portable way to tell an external program to write its
output to a file. Many systems will support
system("gpg blah blah > output.txt");
but most such systems probably also support the (non-standard) popen()
function. As long as you're writing non-portable code anyway, you
might as well do it in a way that avoids creating a superfluous
temporary file.
If you want to be fanatical about portability, you can have some
external source (the user or a config file) specify the command string
to be passed to system(), but I wouldn't bother.
(If you have questions about popen() that aren't answered by your
system's documentation, comp.unix.programmer is the place to ask
them.)