On POSIX systems you can do what you want with popen()
.
Possibly there are other specific ways for specific operating systems (Windows, Android, iOS, MINIX, NeXTSTEP, ...)
Example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char info[1000000]; // 1 Mbytes deve chegar :-)
size_t infolen = 0;
char linha[1000];
size_t linhalen;
char comando[] = "man fprintf";
FILE *processo;
processo = popen(comando, "r");
if (!processo) {
perror("popen");
exit(EXIT_FAILURE);
}
while (fgets(linha, sizeof linha, processo)) {
linhalen = strlen(linha);
if (infolen + linhalen >= sizeof info) {
fprintf(stderr, "O output tem muitas linhas.\n");
exit(EXIT_FAILURE);
}
strcpy(info + infolen, linha);
infolen += linhalen;
}
pclose(processo);
// usa info, por exemplo imprime os 6 primeiros caracteres
printf("%.6s", info);
return 0;
}