Hi,
I have the following code in C (console app):
Code:
int main(int argc, char *argv[])
{
FILE *fp;
char path[1035];
fp = _popen(argv[1], "r");
if (fp == NULL) {
printf("Failed to run command\n");
exit(1);
}
while (fgets(path, sizeof(path) - 1, fp) != NULL) {
printf("%s", path);
}
_pclose(fp);
return 0;
}
The app, as you can see, runs an executable, and prints the output.
What I am trying to do is to gather the output in a string (char).
I had no luck so far; I've tryed to create a buffer - char buffer[1024] - and append to it the results - strcat(buffer,path) - in the while loop instead of printing - printf("%s", path)...
Any ideas are welcomed...
Cheers
JKepler